Probleme beim Laden von ComboBoxen
13.04.2017 13:45:20
ComboBoxen
ich stehe vor folgendem Problem: Ich habe eine Eingabemaske per VBA programmiert und nutze für diese verschiedene Comboboxen. Des Weiteren sind auf der Eingabemaske vier OptionButtons installiert. Je nachdem welcher OptionButton ausgewählt ist, sollen die Comboboxen auch entsprechend mit Inhalt befüllt sein, d.h wird zum Beispiel OptionButton1 ausgewählt, sollen die Comboboxen einen anderen Inhalt haben wie wenn zum Beispiel OptionButton2 ausgewählt wird usw...
Dazu verwende ich folgenden Code:
Private Sub UserForm_Initialize()
Dim i, j As Integer
With Workbooks(ThisWorkbook.Name).Worksheets("Set-up")
' ComboBox laden
i = 24 ' Reihe
j = 1 ' Spalte
Do
If UserForm1.OptionButton1.Value = True Then
If .Cells(i, j).Value = "STATE_" Then
UserForm1.ComboBox1.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "AREA_" Then
UserForm1.ComboBox2.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "RESP" Then
UserForm1.ComboBox3.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "OWNER" Then
UserForm1.ComboBox5.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "MANAGER" Then
UserForm1.ComboBox4.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "TARGET_1" Then
UserForm1.ComboBox6.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "TARGET_2_" Then
UserForm1.ComboBox7.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "TARGET_3_" Then
UserForm1.ComboBox8.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "TYPE" Then
UserForm1.ComboBox9.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PRIO" Then
UserForm1.ComboBox10.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PATH_" Then
UserForm1.ComboBox11.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "SITE_BAY" Then
UserForm1.ComboBox12.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "SITE_HAM" Then
UserForm1.ComboBox13.AddItem .Cells(i, j + 1).Value
End If
ElseIf UserForm1.OptionButton2.Value = True Then
If .Cells(i, j).Value = "STATE_" Then
UserForm1.ComboBox1.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "AREA_" Then
UserForm1.ComboBox2.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "RESP" Then
UserForm1.ComboBox3.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "MANAGER_FE" Then
UserForm1.ComboBox4.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "TYPE" Then
UserForm1.ComboBox9.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PRIO" Then
UserForm1.ComboBox10.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PATH" Then
UserForm1.ComboBox11.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "SITE_BAY" Then
UserForm1.ComboBox12.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "SITE_HAM" Then
UserForm1.ComboBox13.AddItem .Cells(i, j + 1).Value
End If
ElseIf UserForm1.OptionButton3.Value = True Then
If .Cells(i, j).Value = "STATE_" Then
UserForm1.ComboBox1.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "AREA" Then
UserForm1.ComboBox2.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PROJ" Then
UserForm1.ComboBox3.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "OWNER" Then
UserForm1.ComboBox5.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "MANAGER_CD" Then
UserForm1.ComboBox4.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "TARGET_1_" Then
UserForm1.ComboBox6.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "TYPE" Then
UserForm1.ComboBox9.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PRIO" Then
UserForm1.ComboBox10.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PATH" Then
UserForm1.ComboBox11.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "SITE_BAY" Then
UserForm1.ComboBox12.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "SITE_HAM" Then
UserForm1.ComboBox13.AddItem .Cells(i, j + 1).Value
End If
ElseIf UserForm1.OptionButton4.Value = True Then
If .Cells(i, j).Value = "STATE_" Then
UserForm1.ComboBox1.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "AREA" Then
UserForm1.ComboBox2.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PROJ" Then
UserForm1.ComboBox3.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "OWNER" Then
UserForm1.ComboBox5.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "MANAGER_DF" Then
UserForm1.ComboBox4.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "TYPE_(METHOD)_" Then
UserForm1.ComboBox9.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PRIO" Then
UserForm1.ComboBox10.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "PATH" Then
UserForm1.ComboBox11.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "SITE_BAY" Then
UserForm1.ComboBox12.AddItem .Cells(i, j + 1).Value
End If
If .Cells(i, j).Value = "SITE_HAM" Then
UserForm1.ComboBox13.AddItem .Cells(i, j + 1).Value
End If
End If
i = i + 1
Loop Until .Cells(i, j).Value = "" Or i = 400
End With
Noch zur Info: Der Inhalt für die Comboboxen kommt aus dem Reiter "Set-Up" (Spalte 1 und ab Zeile 24).
Im Moment ist es so, dass keine Combobox mit Inhalt gefüllt ist, sondern alle leer sind unabhängig davon welcher OptionButton aktiviert ist. Ich vermute es liegt an dem "i = i + 1" im Code. Kann das sein? Kann mir da jemand weiterhelfen?
Vielen Dank im Voraus und viele Grüße!