AW: Filtern in einer Combobox
25.06.2010 08:56:28
Beverly
Hi,
Option Explicit
Private Sub UserForm_Activate()
Dim objDictionary As Object
Dim Bereich As Variant
Dim loZaehler As Long
Dim arrDaten As Variant
Set objDictionary = CreateObject("Scripting.Dictionary")
With Worksheets("Tabelle1")
Bereich = .Range("A1", .Range("A1").End(xlDown))
End With
For loZaehler = LBound(Bereich) To UBound(Bereich)
objDictionary(Bereich(loZaehler, 1)) = 0
Next
arrDaten = objDictionary.keys
ComboBox1.List = arrDaten
End Sub
Private Sub ComboBox1_Change()
Dim loZeile As Long
ComboBox2.Clear
With Worksheets("Tabelle1")
For loZeile = 1 To IIf(IsEmpty(.Cells(.Rows.Count, 1)), .Cells(.Rows.Count, 1).End(xlUp) _
.Row, .Rows.Count)
If .Cells(loZeile, 1) = ComboBox1 Then ComboBox2.AddItem .Cells(loZeile, 3)
Next loZeile
End With
End Sub