View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pete_UK
 
Posts: n/a
Default vlookup help with two of the same lookups

Assume your example data is in columns A and B exactly as posted, so
you have a heading in A1 and an upper table in A2 to B9, then another
heading in A10 and lower table in A11 to B16. You can define these as
named ranges - Upper = $A$2:$B$9 and Lower = $A$11:$B$16.

Elsewhere on your sheet you use a cell to specify the category you are
interested in (say, cell E1), another cell to specify whether Upper or
Lower (F1 - "U" or "L" specifies), then in cell G1 enter this formula:

=IF(F1="U", VLOOKUP(E1,Upper,2,0),IF(F1="L",VLOOKUP(E1,Lower,2 ,0),"")

So, if you enter "Other" in E1 and "L" in F1, you will get 1 in G1.
Change F1 to "U" and you get 30. If F1 contains anything other than U
or L then G1 displays blank. If the entry in E1 does not match you will
get #N/A.

Hope this helps.

Pete