Thread: vlookup
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
DOR
 
Posts: n/a
Default vlookup

I recommend the following solution:

Put your product table in a separate sheet called Product, in columns
A, B and C. Put nothing else above or below the table in that sheet,
except the headers.

Assuming your Product ID is in C4 of your user form,

In C5 enter =INDEX(Product!B:B,MATCH(C4,Product!A:A,0))

In C6 enter =INDEX(Product!C:C,MATCH(C4,Product!A:A,0))

This may be slightly less efficient that using two VLOOKUP functions
with absolute values of 2 and 3 for the column index numbers but it
protects you against future column insertions in your table that would
throw such VLOOKUP functions off.

If the entered ID does not exist you will get #N/A in C5 and C6. You
can minimize the possibility of this by applying data validation to C4
using the list of IDs in the product table as the source for the
validation. To make that list extensible, it is advisable to define it
as a named dynamic range. See

http://www.contextures.com/xlDataVal01.html

HTH

Declan O'R