VLOOKUP returning #N/A. Lookup value not static number (formula derived number)

muad'ebe

New Member
Joined
Jun 12, 2002
Messages
18
I'm trying to do a VLOOKUP formula where the lookup value is also the tab number (number of tab located in cell Z2).

Cell Z2 has this formula in it =MID(@CELL("Filename",I7),SEARCH("]",@CELL("Filename",I7),1)+1,32)

The Z2 formula results in the cell being populated with a number starting with 1 and increasing by one with every added worksheet. (worksheet added with macro to create any size workbook copying a template as many times as necessary)

How can I get the vlookup to work as it's based on this cell value? If I enter a static number in cell Z2 the formula works. It doesn't work when the lookup value has the above formula in it.

I'm open to any other method to achieve a vlookup type result if it would work.

Thanks for reading and any help you may be able to offer.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
An #N/A error in a VLOOKUP() means the referenced value wasn't found in the array being searched.

It can get confused if the value being returned from your MID() isn't the same data type as what is being searched for in the array. If your VLOOKUP is looking for a specific number in a list of numbers, then the MID() function has to also return a number. You can't lookup number 'stored as text' in a list of numbers stored as numbers.

e.g. "1" isn't the same as 1. Another way is checking the logic: IF("1" = 1,TRUE,FALSE) = FALSE.

So check to make sure that isn't happening.

Other functions that can help you are

=ISNUMBER() determines if a value is considered a number in Excel.
=NUMBERVALUE() converts a number stored as text to a number.

You can wrap your NUMBERVALUE(VLOOKUP()) to convert a VLOOKUP returning a number as text to a number.
 
Upvote 0
Adding to what @Grasor has said, in Z2 try adding this to your formula
=MID(@CELL("Filename",I7),SEARCH("]",@CELL("Filename",I7),1)+1,32)+0
 
Upvote 0
Adding to what @Grasor has said, in Z2 try adding this to your formula
=MID(@CELL("Filename",I7),SEARCH("]",@CELL("Filename",I7),1)+1,32)+0
Peter,

Even simpler-er, I've never actually done it like this but that does coerce a number stored as text to a number. Nice.
 
Upvote 0
Solution
.. another option
Excel Formula:
=--RIGHT(SUBSTITUTE(CELL("Filename",I7),"]",REPT(" ",20)),20)
 
Upvote 0
Adding to what @Grasor has said, in Z2 try adding this to your formula
=MID(@CELL("Filename",I7),SEARCH("]",@CELL("Filename",I7),1)+1,32)+0

Thank you all for the solutions. I used adding the "+0" to the end of the existing formula and everything worked properly after that. Appreciate all the time you all spent responding.
 
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,621
Messages
6,125,884
Members
449,269
Latest member
GBCOACW

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top