Help Needed with WorksheetFunction.VLookup

vba_monkey

Board Regular
Joined
Dec 18, 2013
Messages
112
Hello,

Can anyone please tell me what is wrong with this line of code. The aim is to determine if the field called Search_TB on a UserForm is blank or if whatever value is in that field is not in column 1 of a worksheet called ManSheet.

Code:
If Search_TB = "" Or WorksheetFunction.VLookup(Search_TB, ManSheet.Columns(1), 1, False) = 0 Then

I've tried lots of things but I'm constantly getting this error:

'Unable to get the VLookup property of the WorksheetFunction class'
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
See if this works:

Code:
If Search_TB.Text = "" Or IsError(Application.Match(Search_TB.Text, ManSheet.Columns(1),0)) Then
 
Last edited:
Upvote 0
To add to what Steve the fish posted

Vlookup returns an error when the value is not found, this is why you are getting the error.
 
Upvote 0
Thank you Mr Fish, that does the trick.

Thank you for the explanation, Scott.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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