dimanche 19 avril 2015

Type mismatch error in VBA when adding data to textbox

I am having a textBox and a listbox with list of various cities being populated from excel file


Now each city has one of two option, either within territory or outside. I want that option to be shown in textBox


I tried something like this :



Private Sub CommandButton1_Click()

TextBox2.Value = Application.VLookup(Me.ListBox1.Text,Sheets("Sheet1").Range("B:C"), 2, False)

End Sub


But am getting error saying that Run Time Error 2147352571 (80020005) . Could not set Value property. Type mismatch. Please help to solve this problem


My excel file is something like this


enter image description here


Aucun commentaire:

Enregistrer un commentaire