"Unable to get the VLookup property of the WorksheetFunction Class" error [duplicate] "Unable to get the VLookup property of the WorksheetFunction Class" error [duplicate] vba vba

"Unable to get the VLookup property of the WorksheetFunction Class" error [duplicate]


Try below code

I will recommend to use error handler while using vlookup because error might occur when the lookup_value is not found.

Private Sub ComboBox1_Change()    On Error Resume Next    Ret = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, Worksheets("Sheet3").Range("Names"), 2, False)    On Error GoTo 0    If Ret <> "" Then MsgBox RetEnd Sub

OR

 On Error Resume Next    Result = Application.VLookup(Me.ComboBox1.Value, Worksheets("Sheet3").Range("Names"), 2, False)    If Result = "Error 2042" Then        'nothing found    ElseIf cell <> Result Then        MsgBox cell.Value    End If    On Error GoTo 0


I was having the same problem. It seems that passing Me.ComboBox1.Value as an argument for the Vlookup function is causing the issue. What I did was assign this value to a double and then put it into the Vlookup function.

Dim x As Doublex = Me.ComboBox1.ValueMe.TextBox1.Value = Application.WorksheetFunction.VLookup(x, Worksheets("Sheet3").Range("Names"), 2, False) 

Or, for a shorter method, you can just convert the type within the Vlookup function using Cdbl(<Value>).

So it would end up being

Me.TextBox1.Value = Application.WorksheetFunction.VLookup(Cdbl(Me.ComboBox1.Value), Worksheets("Sheet3").Range("Names"), 2, False) 

Strange as it may sound, it works for me.

Hope this helps.


I was just having this issue with my own program. I turned out that the value I was searching for was not in my reference table. I fixed my reference table, and then the error went away.