Run-time error '1004':

bobkap

Active Member
Joined
Nov 22, 2009
Messages
323
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)
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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!
 
Upvote 0

Forum statistics

Threads
1,223,887
Messages
6,175,199
Members
452,617
Latest member
Narendra Babu D

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top