I am trying to use VLookup in VBA and I am getting
'Unable to get the VLookup property of the worksheetfunction class' error.
I have read in other threads that this could be because the lookup value is not found. For my particular lookup, the values will always be found so this shouldn't be an issue. I have also sorted the lookup table in ascending order as that was another common issue. If I do the same vlookup in a cell it works without any problems
Sub VlookupIssues()
Dim lookUpValue As String
Dim result As Integer
Dim ws As Worksheet: Set ws = Sheets(3)
Dim wsFunc As WorksheetFunction: Set wsFunc = Application.WorksheetFunction
Sheet1.Activate
lookUpValue = Range("B1").Offset(2, 0).Value 'string "HR Manager"
Sheet3.Activate
result = wsFunc.VLookup(lookUpValue, ws.Range("A4:D42"), 3, False)
End sub
The lookup table looks like so (with some rows above/below):