Hi,
I am getting a Run-time error 1004 : Unable to get Vlookup property of the WorksheetFunction class.
I am trying to use a vlookup to find an employee’s name from their employee number and put that into a welcome statement message box.
The “Me.txtUser.Value “ in code below is where the error occurs. If I hard code an employee number, the code works fine.
The “Me.txtUser.Value” is coming from the employee number entered into a userform when the workbook is opened.
Faulty Code:
MyVal = Application.WorksheetFunction.VLookup(Me.txtUser.Value, Sheet2.Range("V8:W1000"), 2, False)
Also on a side note, Dim for MyVal is set to:
Dim MyVal As String
and
Me.txtUser.Value variable is equal to user.
user = Me.txtUser.Value
Thank you in advance for your help.
I am getting a Run-time error 1004 : Unable to get Vlookup property of the WorksheetFunction class.
I am trying to use a vlookup to find an employee’s name from their employee number and put that into a welcome statement message box.
The “Me.txtUser.Value “ in code below is where the error occurs. If I hard code an employee number, the code works fine.
The “Me.txtUser.Value” is coming from the employee number entered into a userform when the workbook is opened.
Faulty Code:
MyVal = Application.WorksheetFunction.VLookup(Me.txtUser.Value, Sheet2.Range("V8:W1000"), 2, False)
Also on a side note, Dim for MyVal is set to:
Dim MyVal As String
and
Me.txtUser.Value variable is equal to user.
user = Me.txtUser.Value
Thank you in advance for your help.