AW: ComboBox
05.11.2007 15:52:06
Thomas
Hallo Andreas,
hier mal mein Vorschlag. Aber Combobox2 mit nur einem Wert macht wenig Sinn, da hätte auch ein Textfeld gereicht denk ich.
Option Explicit
Private Sub UserForm_Initialize()
Dim lZ As Long
lZ = Sheets(2).Range("A65536").End(xlUp).Offset(1, 0).Row
ComboBox1.List = Sheets(2).Range("A1:A" & lZ - 1).Value
If ComboBox1.ListCount > 0 Then ComboBox1.ListIndex = 0
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.ListCount > 0 Then
ComboBox2.Clear
Dim LI As Long
LI = ComboBox1.ListIndex + 1
ComboBox2.AddItem Sheets(2).Cells(LI, 2).Value
ComboBox2.ListIndex = 0
End If
End Sub
Allerdings werden nur Daten in die ComboBox1 geladen, wenn auch etwas in den Zellen steht. Die ganze Spalte wäre etwas viel, meinst nicht?
Gruß Thomas