christian2016
Board Regular
- Joined
- Oct 6, 2016
- Messages
- 123
Hi Guys,
Im trying to use the WorksheetFunction Lookup to store the calculation within the VBA code rather than in a cell within the worksheet.
For some reason I cant get the below code working in VBA although in my sheet its working correctly.
In my worksheet the formula is =IFERROR(LOOKUP(2,1/($B$3:$B$21<=E3)/($C$3:$C$21>=E3),$A$3:$A$21),"Invalid Postcode") and this is working well.
Any help is greatly appreciated.
Thanks
Im trying to use the WorksheetFunction Lookup to store the calculation within the VBA code rather than in a cell within the worksheet.
For some reason I cant get the below code working in VBA although in my sheet its working correctly.
In my worksheet the formula is =IFERROR(LOOKUP(2,1/($B$3:$B$21<=E3)/($C$3:$C$21>=E3),$A$3:$A$21),"Invalid Postcode") and this is working well.
Any help is greatly appreciated.
Thanks
VBA Code:
Dim Postcode As String
Postcode = 3000
x = WorksheetFunction.Lookup(2, 1 / (Range("B3:B21") <= Postcode) / (Range("C3:C21") >= Postcode), Range("A3:A21"), "Invalid Postcode")