I didn't know that. Right now I have data on multiple sheets, say sheets A,B,C. The user hits a button on the main sheet, which triggers VBA to go thru sheets A,B,C to find a match in the 1st column of those sheets with data in the price sheet. This is proving to be time-consuming, as there could be 20-30 values in each sheet (A,B,C) which must be found in the price sheet. I thought vlookup would be quicker than executing an IF loop multiple times.Welcome to the Board!
VLOOKUP is a worksheet function, not a VBA one. So you cannot use it in VBA like that.
This link shows you how you can use it in VBA: Vlookup in Excel VBA
Note that I am NOT saying you cannot use VLOOKUP in VBA. I am just saying your syntax for using it is not correct, as it the function does not natively exist in VBA.I didn't know that. Right now I have data on multiple sheets, say sheets A,B,C. The user hits a button on the main sheet, which triggers VBA to go thru sheets A,B,C to find a match in the 1st column of those sheets with data in the price sheet. This is proving to be time-consuming, as there could be 20-30 values in each sheet (A,B,C) which must be found in the price sheet. I thought vlookup would be quicker than executing an IF loop multiple times.
Dim rng as Range
Set rng=Sheets("model_table").Range("A1:C3500")
xx = WorksheetFunction.VLookup(valvekey, rng, 2, False)