RATE THIS ANSWER
0
Click to Vote:
0
0
There are a couple of things possibly going on here.
1. In VBA you can't call spreadsheet functions directly. You have to use the Application.Worksheetfunction object to access it.
2. The vlookup function can sometimes simply take values, but on other occasions it definitely expects a range. You use the Range function to apply this.
e.g.
answer = Application.WorksheetFunction.Vlookup(x, Range("A1:A100"), 2 false)
or
answer = Application.WorksheetFunction.Vlookup(x, Range("named_range"), 2 false)
or
txtRange = "named_range"
answer = Application.WorksheetFunction.Vlookup(x, Range(txtRange), 2 false)
which gives you control over shich lookup table you access.
Can't comment further without samples of your code.
Last Answered:
Aug 12 2009 2:28 PM GMT by Dgrainge 
70 pts.