Solved

Dynamic Vlookup Function Formula Help

Posted on 2016-11-30
4
37 Views
Last Modified: 2016-11-30
I have the following formula which is not working.

So I am trying to assign the vlookup array location dynamically. I think I am having a problem with the worksheet name (PNL) in this case.

=VLOOKUP(B11,"'PNL'!A"&VLOOKUP(B1,$A$31:$C$45,2,FALSE)& ":N"&VLOOKUP(B1,$A$31:$C$45,3,FALSE),4,FALSE)

When I evaluate the formula, It shows Vlookup("XLF","'PNL'!A14:N38",4,False) and then it gives #Value!

The vlookup function that I create manually work fine (=VLOOKUP(B11,'PNL'!$A$14:$N$38,4,FALSE)), so the data is there. But my dynamic formula doesn't work. I think the problem is with the name of the spreadsheet. Or maybe something else?
0
Comment
Question by:awesomejohn19
  • 2
4 Comments
 
LVL 6

Expert Comment

by:Mike in IT
ID: 41907570
First off, this part of your dynamic vlookup has to return a number VLOOKUP(B1,$A$31:$C$45,2,FALSE). Then you should try CONCATENATE to put it all together like this:

=VLOOKUP(B11,CONCATENATE("'PNL'!$A",VLOOKUP(B1,$A$31:$C$45,2,FALSE),":N",VLOOKUP(B1,$A$31:$C$45,3,FALSE)),4,FALSE)

Open in new window


I can't test it very well, but it works for me like that.
0
 

Author Comment

by:awesomejohn19
ID: 41907583
Hi Michael , when I put your version it brings the following when I do the Evaluate formula

Vlookup("XLF","'PNL!$A14:N38",4,FALSE)

But is still results #VALUE!
0
 
LVL 21

Accepted Solution

by:
Ejgil Hedegaard earned 500 total points
ID: 41907620
"'PNL'!A14:N38" is a text, not a range.
To convert to a range, use the indirect function.
So the formula must be

=VLOOKUP(B11,INDIRECT("'PNL'!A"&VLOOKUP(B1,$A$31:$C$45,2,FALSE)& ":N"&VLOOKUP(B1,$A$31:$C$45,3,FALSE)),4,FALSE)
0
 

Author Closing Comment

by:awesomejohn19
ID: 41907628
Excellent
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now