Populating combo boxes
Private Sub Userform_Initialize()
ComboBox1.Clear
ComboBox2.Clear
ComboBox3.Clear
ComboBox1.Value = ""
ComboBox2.Value = ""
ComboBox3.Value = ""
ComboBox1.AddItem "Qrt1"
ComboBox1.AddItem "Qrt2"
ComboBox1.AddItem "Qrt3"
ComboBox1.AddItem "Qrt4"
End Sub
Private Sub Combobox1_Click()
Dim lngVal As Long, i As Long
ComboBox2.Clear
ComboBox3.Clear
ComboBox2.Value = ""
ComboBox3.Value = ""
lngVal = ComboBox1.ListIndex
For i = lngVal * 3 + 1 To lngVal * 3 + 3
ComboBox2.AddItem Format(DateSerial(2003, i, 1), "mmm")
Debug.Print Format(DateSerial(2003, i, 1), "mmm")
Next
End Sub
Private Sub Combobox2_Click()
ComboBox3.Clear
ComboBox3.List = Range(ComboBox2.Text).Value
End Sub
--
Regards,
Tom Ogilvy
"Cecilkumara Fernando" wrote in message
...
Hi All,
I have 12 named ranges say Jan,Feb,.........Dec
these 12 ranges falls in 4 categories say Qrt1, Qrt2, Qrt3, Qrt4
so I make another 4 lists, 1st one, Jan,Feb,Mar and named it as Qrt1 so
on.
Can I have 3 comboboxes in a userform so that 1st one shows Qrt1,Qrt2,
Qrt3,
Qrt4 and when Qrt3 is selected the 2nd combobox populate with the list
Jul,Aug,Sep and when Aug is selected the 3rd combobox populate with the
list
named Aug.
A sample code is very much appreciated.
Cecil
|