UserForm / ComboBox Change
19.08.2003 07:31:56
Erich M.
habe eine neue Frage, die ich trotz mehrerer Versuche noch nicht ganz lösen konnte:
Wenn ich in einer ComboBox eine Auswahl anklicke, soll die ListBox2 entsprechend gefüllt werden. Ich habe zwar eine Lösung, die aber sicher verbessert (vereinfacht) werden kann:
Private Sub ComboBox1_Change()
Worksheets("Tabelle2").Activate
With Worksheets("Tabelle2")
If .[a65536] = "" Then
LoLetzte = .[a65536].End(xlUp).Row
Else
LoLetzte = 65536
End If
ListBox2.ColumnCount = 1
If ComboBox1.ListIndex = -1 Then Exit Sub
If ComboBox1.ListIndex = 0 Then
m = 1
For LoI = 1 To 10
ListBox2.AddItem Format(.Cells(LoI, m))
ListBox2.List(LoI - 1, m) = .Cells(LoI, m)
Next LoI
End If
If ComboBox1.ListIndex = 1 Then
m = 2
For LoI = 1 To 10
ListBox2.AddItem Format(.Cells(LoI, m))
ListBox2.List(LoI - 1, m) = .Cells(LoI, m)
Next LoI
End If
If ComboBox1.ListIndex = 2 Then
m = 3
For LoI = 1 To 10
ListBox2.AddItem Format(.Cells(LoI, m))
ListBox2.List(LoI - 1, m) = .Cells(LoI, m)
Next LoI
End If
If ComboBox1.ListIndex = 3 Then
m = 4
For LoI = 1 To 10
ListBox2.AddItem Format(.Cells(LoI, m))
ListBox2.List(LoI - 1, m) = .Cells(LoI, m)
Next LoI
End If
End With
End Sub
Code eingefügt mit: Excel Code Jeanie
Besten Dank für ine Hilfe!
mfg
Erich