PDA

View Full Version : Solved: Filling comboboxes with filtered data



Bramo
07-30-2008, 11:22 AM
Hi,

I have two comboboxes in a form. Combobox1 contains a set list as so:

Site 1
Site 2
Site 3

This then autofilters the table, so if site 1 is selected, then all rows with site 1 are filtered.

I then have a second combobox, combobox2, which I need to fill with information from Column D that have only been filtered in combobox 1. Code ive tried so far:

Private Sub Combobox2_Change()

With Combobox2

.clear
.additem (Range("D1:D1000").specialcells(xlCellTypeVisible).value)

End With

End Sub

The data is constantly updated so I cant have fixed data in combobox2. I would be most grateful for some help!

Al.

Bob Phillips
07-30-2008, 12:16 PM
Private Sub ComboBox2_DropButtonClick()
Dim cell As Range

With ComboBox2

.Clear
For Each cell In Range("D1:D1000").SpecialCells(xlCellTypeVisible)

.AddItem cell.Value
Next cell
End With

End Sub

Bramo
07-31-2008, 12:57 AM
Thanks very much! :)