Hello,
I would like to ask some help regarding listbox. My target is that if I select a country in combox1 then I would like to see only those cities which are in that country.
Could somebody help me how to do this?
Hello,
I would like to ask some help regarding listbox. My target is that if I select a country in combox1 then I would like to see only those cities which are in that country.
Could somebody help me how to do this?
Hi there,
it is a simple bit of code:
test.xlsmPrivate Sub ComboBox1_Change() Me.ListBox1.Clear With Sheets("Sheet1") For xrow = 11 To .Cells(11, 3).End(xlDown).Row If .Cells(xrow, 3) = Me.ComboBox1.Value Then Me.ListBox1.AddItem .Cells(xrow, 4) Next xrow End With End Sub
Hope it helps
Regards
Miroslav R.
(If You like my solutions, feel free to add reputation.)
Hi
Check this pls.
Regards
Fotis.
-This is my Greek whisper to Europe.
--Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.
Advanced Excel Techniques: http://excelxor.com/
--KISS(Keep it simple Stupid)
--Bring them back.
---See about Acropolis of Athens.
--Visit Greece.
Try this...
TIP: do not use the End command to exit your userform. The End command stops all code execution (not just the userform) and could have unintended consequences.Private Sub ComboBox1_Change() Dim v As Variant, i As Long Me.ListBox1.Clear If Me.ComboBox1.ListIndex > -1 Then With Sheets("Sheet1") v = .Range("C2", .Range("D" & Rows.Count).End(xlUp)).Value End With For i = LBound(v, 1) To UBound(v, 1) If Me.ComboBox1.Value = v(i, 1) Then Me.ListBox1.AddItem v(i, 2) Next i End If End Sub Private Sub CommandButton1_Click() Unload Me End Sub
Surround your VBA code with CODE tags e.g.;
[CODE]your VBA code here[/CODE]
The # button in the forum editor will apply CODE tags around your selected text.
Hello Guys,
Thank you the help, all of answer very useful for me.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks