I have an HLOOKUP function that works in a spread sheet referencing a named range, but I cannot get it to work in a VBA Macro.
In the spread sheet, the function is as follows:
JN.10634 is the named range, and the lookup works, finding the date and returning the value on the row below.
In my vba macro, I am assigning a cell value with the following statement:
Date28 is a variable assigned the value 12/12/16
The code is failing on the variable fixedName and giving the error "Unable to get the HLOOKUP property of the WorksheetFunction class".
During debug mode with the cursor on the fixedName variable it shows the following:
fixedName = "JN.10634"
Any ideas why is knows the variable resolves to JN.10634 (which is the name of a named range) but it generates an error?
In the spread sheet, the function is as follows:
Code:
=HLOOKUP(DATEVALUE("12/12/16"),JN.10634, 2, FALSE)
JN.10634 is the named range, and the lookup works, finding the date and returning the value on the row below.
In my vba macro, I am assigning a cell value with the following statement:
Code:
.Cells(8, 12).Value = WorksheetFunction.HLookup(DateValue(Date28), fixedName, 2, False)
Date28 is a variable assigned the value 12/12/16
The code is failing on the variable fixedName and giving the error "Unable to get the HLOOKUP property of the WorksheetFunction class".
During debug mode with the cursor on the fixedName variable it shows the following:
fixedName = "JN.10634"
Any ideas why is knows the variable resolves to JN.10634 (which is the name of a named range) but it generates an error?