As a new user of vba i have created a user form to enter doctors database. in the form i have
combobox1 Row source worksheet 'Teritory!A2:A52'
TextBox2 to generate a code(A,B,C...) based on the area. Source of the Area code is 'Teritory!B2:B52'
My code is as follows
Working fine unless i am entering an area which is not included in the list. if i enter a area which is not in the list ('Teritory!a2:a52) i am getting an error massage 'Run time error 1004 unable to get the vlookup property of the worksheet function class' . Please help me to handle the error.Dim X As String Dim Y As String Sheets("Teritory").Select X = ComboBox1.Value If X <> "" Then Y = Application.WorksheetFunction.VLookup(ComboBox1.Value, Range("A2:B52"), 2, False) TextBox2.Value = Y Else TextBox2.Value = ""
Bookmarks