Link to home
Start Free TrialLog in
Avatar of A G
A GFlag for United States of America

asked on

Dynamic Vlookup Function Formula Help

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?
Avatar of Mike in IT
Mike in IT
Flag of United States of America image

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.
Avatar of A G

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of Ejgil Hedegaard
Ejgil Hedegaard
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of A G

ASKER

Excellent