Live-Forum - Die aktuellen Beiträge
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

5 Comboboxen

Forumthread: 5 Comboboxen

5 Comboboxen
07.12.2015 14:25:42
Wälchli
Guten Tag miteinander
Ich bin neu hier und wäre um eure Hilfe sehr dankbar.
Ich habe eine UserForm mit 5 ComboBoxen. Wie bringe ich es fertig, dass
1. keine Debugg-Meldung mehr erscheint (Laufzeitfehler 13, Typen unverträglich) und
2. die ComboBoxen vom Sheet Rohdaten gefüllt werden?
https://www.herber.de/bbs/user/102061.xlsm
Herzlichen Dank für eure Hilfe

Anzeige

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: 5 Comboboxen
07.12.2015 19:48:57
Nepumuk
Hallo,
da waren die Abfragen und die Collection an der falschen Stelle.
Option Explicit

Private Sub ComboBox1_Enter()
    Dim aRow, iRow As Long
    Dim col As New Collection
    With Me
        .ComboBox1.Clear
        Sheets("Rohdaten").Select
        aRow = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
        On Error Resume Next
        For iRow = 2 To aRow
            col.Add Cells(iRow, 1), Cells(iRow, 1)
            If Err = 0 Then
                .ComboBox1.AddItem Cells(iRow, 1)
            Else
                Err.Clear
            End If
        Next iRow
        On Error GoTo 0
    End With
End Sub

Private Sub ComboBox2_Enter()
    Dim aRow, iRow As Long
    Dim col As New Collection
    With Me
        .ComboBox2.Clear
        Sheets("Rohdaten").Select
        aRow = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
        On Error Resume Next
        For iRow = 2 To aRow
            If Cells(iRow, 1) = .ComboBox1.Value Then
                col.Add Cells(iRow, 2), Cells(iRow, 2)
                If Err = 0 Then
                    .ComboBox2.AddItem Cells(iRow, 2)
                Else
                    Err.Clear
                End If
            End If
        Next iRow
        On Error GoTo 0
    End With
End Sub

Private Sub ComboBox3_Enter()
    Dim aRow, iRow As Long
    Dim col As New Collection
    With Me
        .ComboBox3.Clear
        Sheets("Rohdaten").Select
        aRow = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
        On Error Resume Next
        For iRow = 2 To aRow
            If Cells(iRow, 1) = .ComboBox1.Value And _
                Cells(iRow, 2) = .ComboBox2.Value Then
                col.Add Cells(iRow, 3), Cells(iRow, 3)
                If Err = 0 Then
                    .ComboBox3.AddItem Cells(iRow, 3)
                Else
                    Err.Clear
                End If
            End If
        Next iRow
        On Error GoTo 0
    End With
End Sub

Private Sub ComboBox4_Enter()
    Dim aRow, iRow As Long
    Dim col As New Collection
    With Me
        .ComboBox4.Clear
        Sheets("Rohdaten").Select
        aRow = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
        On Error Resume Next
        For iRow = 2 To aRow
            If Cells(iRow, 1) = .ComboBox1.Value And _
                Cells(iRow, 2) = .ComboBox2.Value And _
                Cells(iRow, 3) = .ComboBox3.Value Then
                col.Add Cells(iRow, 4), Cells(iRow, 4)
                If Err = 0 Then
                    .ComboBox4.AddItem Cells(iRow, 4)
                Else
                    Err.Clear
                End If
            End If
        Next iRow
        On Error GoTo 0
    End With
End Sub

Private Sub ComboBox5_Enter()
    Dim aRow, iRow As Long
    Dim col As New Collection
    With Me
        .ComboBox5.Clear
        Sheets("Rohdaten").Select
        aRow = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
        On Error Resume Next
        For iRow = 2 To aRow
            If Cells(iRow, 1) = .ComboBox1.Value And _
                Cells(iRow, 2) = .ComboBox2.Value And _
                Cells(iRow, 3) = .ComboBox3.Value And _
                Cells(iRow, 4) = .ComboBox4.Value Then
                col.Add Cells(iRow, 5), Cells(iRow, 5)
                If Err = 0 Then
                    .ComboBox5.AddItem Cells(iRow, 5)
                Else
                    Err.Clear
                End If
            End If
        Next iRow
        On Error GoTo 0
    End With
End Sub

Gruß
Nepumuk

Anzeige
AW: 5 Comboboxen
08.12.2015 07:12:03
Wälchli
Hallo Nepumuk
Ganz herzlichen Dank für deine Hilfe.
Wohl ist die Fehlermeldung LZF13 weg, jedoch habe ich jetzt bereits wieder eine neue Fehlermeldung erhalten:
Laufzeitfehler 457: Dieser Schlüssel ist bereits einem Element dieser Auflistung zugeordnet.
Diese Meldung erscheint, wenn ich auf die ComboBox1 klicke und zwar bezieht sie sich auf die Zeile
col.Add Cells(iRow, 1), Cells(iRow, 1)
Ich habe nun - analog den cmb2 bis cmb5 eine Zeile im Code eingefügt:
For iRow = 2 To aRow
If Cells(iRow, 1) = .ComboBox1.Value Then
col.Add Cells(iRow, 1), Cells(iRow, 1)
If Err = 0 Then
.ComboBox1.AddItem Cells(iRow, 1)
Mit diesem Zusatz erhalte ich wohl keine Fehlermeldung mehr - aber die ComboBoxen werden auch nicht gefüllt.
Hast du vielleicht dazu noch eine Lösung?

Anzeige
AW: 5 Comboboxen
08.12.2015 07:17:00
Nepumuk
Hallo,
hast du im VBA-Editor unter Extras - Optionen - Reiter Allgemein - Unterbrechen bei Fehlern - die Option "Bei allen Fehlern" ausgewählt? Wenn ja, dann ändere das auf "In Klassenmodul".
Gruß
Nepumuk

AW: 5 Comboboxen
08.12.2015 07:32:40
Wälchli
Nepumuk - bist du Informatiker oder Forensiker?
Darauf wäre ich nie und nimmer gekommen. Es funktioniert!
Ganz herzlichen Dank für deine Hilfe!
Anzeige
;

Forumthreads zu verwandten Themen

Anzeige
Anzeige
Anzeige
Entdecke relevante Threads

Schau dir verwandte Threads basierend auf dem aktuellen Thema an

Alle relevanten Threads mit Inhaltsvorschau entdecken

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige