I have a userform that has a txtZip, Listbox1, & ComboBox1, cmdGetCity
I want a function that whenever cmdGetCity is clicked, it will search the B2:B81832 range for a zipcode that matches txtZip (entered by user) and, also, search E2:E81832 for data that the users selects in the Combobox 1 (State - selected by user). All entries i would like to be displayed in Listbox1.
This is what I have, but I keep getting an error 'Type Mismatch' - I'm rusty on vb, but this is my first time doing vba for excel:
I want a function that whenever cmdGetCity is clicked, it will search the B2:B81832 range for a zipcode that matches txtZip (entered by user) and, also, search E2:E81832 for data that the users selects in the Combobox 1 (State - selected by user). All entries i would like to be displayed in Listbox1.
This is what I have, but I keep getting an error 'Type Mismatch' - I'm rusty on vb, but this is my first time doing vba for excel:
Code:
Private Sub cmdGetCity_Click()
If (txtZip = Worksheets("Zipcodes").Range("B2:B81832")) & (ComboBox1 = Worksheets("Zipcodes").Range("E2:E81832")) Then
ListBox1.List = Worksheets("Zipcodes").Text("D")
End If
End Sub