ich möchte prüfen ob die ComboBox Einträge mit den Tabellenblatt Einträgen
übereinstimmen.
Leider kommt immer "Kein Eintrag"
Danke!
Gruß
Sigi
https://www.herber.de/bbs/user/129292.xlsm
Private Sub CommandButton2_Click()
Dim RaFound As Range
If ComboBox2 "" Then
Set RaFound = Columns(2).Find(ComboBox2, Range("B" & Rows.Count), xlFormulas, _
xlWhole, , xlNext)
End If
If RaFound Is Nothing Then
If ComboBox1 "" Then
Set RaFound = Columns(4).Find(ComboBox1, Range("D" & Rows.Count), xlFormulas, _
xlWhole, , xlNext)
End If
If RaFound Is Nothing Then
If ComboBox3 "" Then
Set RaFound = Columns(3).Find(ComboBox3, Range("C" & Rows.Count), xlFormulas, _
xlWhole, , xlNext)
End If
End If
End If
If Not RaFound Is Nothing Then
MsgBox "Eintrag vorhanden"
Else
MsgBox "Kein Eintrag"
End If
End Sub
Private Sub CommandButton2_Click()
Dim bFlag As Boolean
With Worksheets("Tabelle1")
If Me.ComboBox1 "" And Me.ComboBox2 "" And Me.ComboBox3 "" Then
If WorksheetFunction.CountIf(.Columns(2), Me.ComboBox2) > 0 Then
If WorksheetFunction.CountIf(.Columns(4), Me.ComboBox1) > 0 Then
If WorksheetFunction.CountIf(.Columns(3), CLng(Me.ComboBox3)) > 0 Then
bFlag = True
End If
End If
End If
Else
MsgBox "Bitte Werte in Combobox wählen."
Exit Sub
End If
If bFlag Then
MsgBox "Eintrag vorhanden."
Else
MsgBox "Kein Eintrag."
End If
End With
bFlag = False
End Sub
Gruß WerenerPrivate Sub CommandButton2_Click()
Dim bFlag As Boolean, i As Long
With Worksheets("Tabelle1")
If Me.ComboBox1 "" And Me.ComboBox2 "" And Me.ComboBox3 "" Then
For i = 2 To .Cells(.Rows.Count, 2).End(xlUp).Row
If Not IsEmpty(.Cells(i, 2)) Then
If WorksheetFunction.CountIfs(.Cells(i, 2), Me.ComboBox2, .Cells(i, 3), _
CLng(Me.ComboBox3), .Cells(i, 4), Me.ComboBox1) > 0 Then
bFlag = True
Exit For
End If
End If
Next i
Else
MsgBox "Bitte Eintrag in Combobox wählen."
Exit Sub
End If
End With
If bFlag Then
MsgBox "Eintrag vorhanden."
Else
MsgBox "Kein Eintrag."
End If
End Sub
Gruß Werner