I need to do a vlookup through a range of cells, and depending on it returning a value or a #N/A, I want to do some action on it.
I tried to place the vlookup inside the iserror function but that didn't work.
This is what i tried next but is also not working:
Set costCentreMapping = Workbooks.Open(Filename:="C:\mapping.xlsx")
Sheets("Sheet2").Activate
Dim CostCentreRange As Range
Set CostCentreRange = Range("A4:E2967")
Set test1 = Application.WorksheetFunction.VLookup(appid, CostCentreRange, 2, False)
If IsError(test1) Then
appid.Offset(columnoffset:=15) = "value1"
End If
What do you recommed me to do?
Thanks
.WorksheetFunctionfrom both VLOOKUPS. This will allow the passing of the error into the variable.Setting with theVLookup? what value are you trying to get from it ?