20.10.2015, 11:33
Guten Tag Zusammen,
ich hab zwei Comboboxen die jeweils abhängig von einander sind.
Mein Code funktioniert auch sehr gut so weit, aber der soll erst ab der 4. Zeile Anfangen, das kriege ich nicht.
Könnt ihr den mir bitte vebessern?
Wenn ihr auch einen anderen Code habt den ihr besser findet nur her damit.
Gruß Joe
ich hab zwei Comboboxen die jeweils abhängig von einander sind.
Mein Code funktioniert auch sehr gut so weit, aber der soll erst ab der 4. Zeile Anfangen, das kriege ich nicht.
Könnt ihr den mir bitte vebessern?
Code:
Option Explicit
Dim aRow As Long
Dim col As New Collection
Dim iRow, x As Long
Private Sub cbo1_Change()
cbo2.Clear
On Error Resume Next
For iRow = 2 To aRow
col.Add Cells(iRow, 8), Cells(iRow, 8)
If Err = 0 And Cells(iRow, 7) = cbo1.Value Then
cbo2.AddItem Cells(iRow, 8)
Else
Err.Clear
End If
Next iRow
On Error GoTo 0
For x = col.Count To 1 Step -1
col.Remove (x)
Next x
Private Sub UserForm_Initialize()
'Auswahl für die ComboBox Profil
aRow = IIf(IsEmpty(Worksheets("Tabellen").Range("G4:G65536")), Worksheets("Tabellen").Range("G4:G65536").End(xlUp).Row, 65536)
On Error Resume Next
For iRow = 2 To aRow
col.Add Cells(iRow, 7), Cells(iRow, 7)
If Err = 0 Then
cbo1.AddItem Cells(iRow, 7)
Else
Err.Clear
End If
Next iRow
On Error GoTo 0
Wenn ihr auch einen anderen Code habt den ihr besser findet nur her damit.
Gruß Joe