FunsizedNerd
New Member
- Joined
- Mar 20, 2019
- Messages
- 17
Trying to look up a value within a range using vlookup. If the value doesn't exist, then I want it to return either 0, nothing etc
Then I can use an if statement on the variable, so that if it IS nothing then I can do something (add the missing value to the end of a range)
It works fine if the value can be found within the range, but the second I come across one that isn't there, I get
Run-time error '1004': Unable to get the Vlookup property of the WorksheetFunction class
I know you can't use VLookup, that's why I have the IfError
Then I can use an if statement on the variable, so that if it IS nothing then I can do something (add the missing value to the end of a range)
Code:
test = Application.WorksheetFunction.IfError(Application.WorksheetFunction.VLookup(cl.Value, checkvalues, 1, 0), 0)
It works fine if the value can be found within the range, but the second I come across one that isn't there, I get
Run-time error '1004': Unable to get the Vlookup property of the WorksheetFunction class
I know you can't use VLookup, that's why I have the IfError