Hier ist mein ganzer Code für den Suchen Button. Hoffe das hilft weiter.
Option Explicit
Private Sub cmdsuchen_Click()
With ThisWorkbook.Sheets("bundesliga_Spieler")
Dim strSpielername As String
Dim lngSpielerBuchstabe As Long
Dim booTreffer As Boolean
Dim lngSuchBuchstabe As Long
Dim lngRow As Long
Dim booLandLigaVerein As Boolean
lngRow = 2
cmdclearergebnis.BackColor = RGB(255, 255, 0)
'Ändern der Farbe des Buttons "Neue Suche" in gelb,
'um den User darauf aufmerksam zu machen eine neue Suche auszuführen
Do While .Cells(lngRow, 4) <> ""
strSpielername = .Cells(lngRow, 4)
'Alle Spielernamen werden in Spalte 4 definiert
For lngSuchBuchstabe = 1 To Len(txtsuche)
booTreffer = False
For lngSpielerBuchstabe = 1 To Len(strSpielername)
If Mid(strSpielername, lngSpielerBuchstabe, 1) = Mid(txtsuche, lngSuchBuchstabe, 1) Then booTreffer = True
Next lngSpielerBuchstabe
If booTreffer = False Then Exit For
Next lngSuchBuchstabe
'Durchsuche nacheinander die Buchstaben auf einen Treffer
If booTreffer = True Or Len(txtsuche) = 0 Then
booLandLigaVerein = True
If cboLand <> "" Then
If cboLand <> .Cells(lngRow, 5) Then booLandLigaVerein = False
End If
If cboLiga <> "" Then
If CLng(cboLiga) <> .Cells(lngRow, 10) Then booLandLigaVerein = False
End If
If cboVerein <> "" Then
If cboVerein <> .Cells(lngRow, 9) Then booLandLigaVerein = False
End If
If booLandLigaVerein And _
((chk09 = True And .Cells(lngRow, 3) >= 0 And .Cells(lngRow, 3) < 10) Or _
(chk1019 = True And .Cells(lngRow, 3) > 9 And .Cells(lngRow, 3) < 20) Or _
(chk2029 = True And .Cells(lngRow, 3) > 19 And .Cells(lngRow, 3) < 30) Or _
(chk3039 = True And .Cells(lngRow, 3) > 29 And .Cells(lngRow, 3) < 40) Or _
(chk4049 = True And .Cells(lngRow, 3) > 39 And .Cells(lngRow, 3) < 50) Or _
(chk49 = True And .Cells(lngRow, 3)) > 49) And _
((opt09 = True And .Cells(lngRow, 7) >= 0 And .Cells(lngRow, 7) < 10) Or _
(opt1019 = True And .Cells(lngRow, 7) > 9 And .Cells(lngRow, 7) < 20) Or _
(opt2029 = True And .Cells(lngRow, 7) > 19 And .Cells(lngRow, 7) < 30) Or _
(optegal = True And .Cells(lngRow, 7) >= 0 And .Cells(lngRow, 7) < 300) Or _
(opt29 = True And .Cells(lngRow, 7)) > 29) And _
((optv09 = True And .Cells(lngRow, 8) >= 0 And .Cells(lngRow, 8) < 10) Or _
(optv1019 = True And .Cells(lngRow, 8) > 9 And .Cells(lngRow, 8) < 20) Or _
(optv2029 = True And .Cells(lngRow, 8) > 19 And .Cells(lngRow, 8) < 30) Or _
(optvegal = True And .Cells(lngRow, 8) >= 0 And .Cells(lngRow, 8) < 300) Or _
(optv29 = True And .Cells(lngRow, 8)) > 29) Then
Call AddSortedToBox(lstergebnis, strSpielername)
.Rows(lngRow).Interior.Color = RGB(0, 255, 0)
'Wenn die Eingegebenen Werte mit denen aus der
'Datenbank übereinstimmen, gebe die Namen in das Ergebnis aus
End If
End If
lngRow = lngRow + 1
Loop
End With
If chk09 = False And chk1019 = False And chk2029 = False And chk3039 = False And chk4049 = False And chk49 = False Then
MsgBox ("Bitte wähle mindestens eine Trikotnummer aus")
'Wenn keine Trikotnummer ausgewählt wurde, weise den
'Nutzer darauf hin, dass eine ausgewählt werden muss.
End If
End Sub
|