To give a bit of a primer on VLOOKUP:
Here's a lookup table -- animals with a classification in the second column
Excel 2010
| M | N |
---|
Animal | Classification | |
Cat | Mammal | |
Dog | Mammal | |
Axolotl | Amphibian | |
Sparrow | Bird | |
Canary | Bird | |
Skink | Reptile | |
Llama | Mammal | |
Coyote | Mammal | |
Budgie | Bird | |
Emu | Bird | |
Bull Shark | Fish | |
Telapia | Fish | |
<tbody>
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]9[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]11[/TD]
[TD="align: center"]12[/TD]
[TD="align: center"]13[/TD]
</tbody>
Sheet1
And here's a main data table (only 1 column) that uses VLOOKUP to pull in the correct classification.
Excel 2010
| A | B |
---|
Animal | Classification | |
Cat | Mammal | |
Dog | Mammal | |
Axolotl | Amphibian | |
Sparrow | Bird | |
Canary | Bird | |
Skink | Reptile | |
Llama | Mammal | |
Coyote | Mammal | |
Budgie | Bird | |
Emu | Bird | |
Bull Shark | Fish | |
Telapia | Fish | |
<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]9[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]11[/TD]
[TD="align: center"]12[/TD]
[TD="align: center"]13[/TD]
</tbody>
Sheet1
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]B2[/TH]
[TD="align: left"]=VLOOKUP(
A2,$M$2:$N$13,2,FALSE)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
A2 is the value that you want to look up. M2:N13 (absolute ref) is the lookup table. 2 is the column of the table (must always be to the right of the lookup column), and FALSE means that you want an exact match.
In your code you can use WorksheetFunction.VLOOKUP to call the function, then use the above syntax. That should get you down to a handful of Case statements. Something like:
Code:
Select Case WorksheetFunction.VLOOKUP(Cells(Rw,2),Sheets("Lookup").Range("A2:B250"),2,FALSE)
Case "Food"
Case "Beverage"
Case "Non-Food"
End Select
Denis