Run-time error '1004':

bobkap

Board Regular
Joined
Nov 22, 2009
Messages
234
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
I have the following line of code in my macro but it will not work. I keep getting that error message along with "Unable to get the VLookup property of the WorksheetFunction class.

After guessing and trying many different ways to fix it, I've given up. Any help would be greatly appreciated!

payrate = Application.WorksheetFunction.VLookup(empname, Table1, Banana, False)
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,309
WorksheetFunction causes a breaking error when an error occurs as a result of no match being found. Try the following instead...

Code:
Dim payrate As Variant


payrate = Application.VLookup(empname, Table1, Banana, False)

Now you'll be able to test whether a match has been found...


Code:
If IsError(payrate) Then
    MsgBox "No match found.", vbInformation
Else
    MsgBox "Match found.", vbInformation
End If

Hope this helps!
 

Watch MrExcel Video

Forum statistics

Threads
1,109,451
Messages
5,528,834
Members
409,839
Latest member
akashsadhu
Top