Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# tweeking a vlookup

Posted on 2013-12-26
Medium Priority
228 Views
=VLOOKUP(A2,'Wed by ZIP'!\$A\$2:\$C\$416,3,FALSE)

Simple so far.  The above is my lookup. How can I make the range more flexible without justing naming a range( I have reasons). I want to put the reference for \$c\$416  a cell reference on sheet called "Wed by ZIP" and a reference will be in cell G2. Thanks.
0
Question by:dnewman33

LVL 31

Expert Comment

ID: 39740132
what do you mean by:
How can I make the range more flexible

???
not clear
gowflow
0

Author Comment

ID: 39740174
I want the "416" to be a reference in a cell so I can easily change it to any figure based on new length of rows on the sheet. A simple reference to a cell didn't work in the formula.
0

LVL 50

Accepted Solution

barry houdini earned 500 total points
ID: 39740186
If you have the number 416 in Wed by Zip worksheet, cell G2 then try using INDEX like this

=VLOOKUP(A2,'Wed by ZIP'!\$A\$2:INDEX('Wed by ZIP'!\$C:\$C,'Wed by ZIP'!\$G\$2),3,FALSE)

INDIRECT is also possible like this

=VLOOKUP(A2,INDIRECT("'Wed by ZIP'!\$A\$2:\$C\$"&'Wed by ZIP'!\$G\$2),3,FALSE)

but INDEX is normally preferable

regards, barry
0

LVL 81

Assisted Solution

byundt earned 500 total points
ID: 39740239
On worksheet Wed by ZIP, is there anything under your table in A2:C416? If not, consider making the range of rows being searched much larger than your actual data. For example, you could use:
=VLOOKUP(A2,'Wed by ZIP'!\$A\$2:\$C\$5000,3,FALSE)

VLOOKUP starts looking for the value in A2 in the first row of the lookup table, and continues until it finds a match. There is no penalty to making the number of rows in the table far exceed your data as long as the data is found. By increasing the number of rows potentially being searched by a factor of 12, you will probably be long retired before you run into a problem with that formula.

Such an overprovisioning approach is easy to understand (by you or by others), simple to implement, and quite flexible.
0

## Featured Post

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.