Getting Run Time Error in Excel VBA Vlookup Userform

zanzara

New Member
Joined
Oct 16, 2015
Messages
2
Hello,

I have the following code producing a run time error. It actually works and and gives me the proper output but it also gives me a run time error '13' for some reason.
The purpose of this code is when a user chooses a Family Name from a combo box, a field called txtFamilyID is populated with a number associated with the Family Name chosen.
Below is the snippet of the code within the "Hours Form". The bolded code gets highlighted when the form is executed.

Private Sub HoursForm_Initialize()
cbFamilyName.List = Sheets("Names").Range("A1:A200").Value
End Sub

Private Sub cbFamilyName_Change()
txtFamilyID.Text = Application.VLookup(Me.cbFamilyName.Value, Sheets("Names").Range("A1:B200"), 2, 0)
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
RESOLVED!! The code is correct. I had an issue in the the 'Clear Form code that was causing the issue.
 
Upvote 0

Forum statistics

Threads
1,214,529
Messages
6,120,070
Members
448,943
Latest member
sharmarick

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