Der bisherige Code lautet:
Option Explicit
Private Sub cmdsuchen_Click()
'Suchmakro aufrufen:
Suchen
End Sub
Sub Suchen()
Dim strKostArt As String, strDetail As String, strG As String, strBetrag As String, strDat As String
Dim arWerte As Variant, lngZeile As Long, Spalte As Integer
'Liste leeren:
ListBox1.Clear
ListBox1.ColumnCount = 5
'Suchkriterien:
strKostArt = txtKostenart.Text
strDetail = txtDetails.Text
strG = txtg.Text
strBetrag = txtBetrag.Text
strDat = txtDatum.Text
'Werte in Array:
lngZeile = Cells.Find("*", , , , xlByRows, xlPrevious).Row
arWerte = Range(Cells(1, 1), Cells(lngZeile, 5)).Value
'Zeile für Zeile überprüfen
For lngZeile = 1 To UBound(arWerte, 1)
If arWerte(lngZeile, 1) = strKostArt Or strKostArt = "" Then
If arWerte(lngZeile, 2) = strDetail Or strDetail = "" Then
If arWerte(lngZeile, 3) = strG Or strG = "" Then
If arWerte(lngZeile, 4) = strBetrag Or strBetrag = "" Then
If arWerte(lngZeile, 5) = strDat Or strDat = "" Then
ListBox1.AddItem arWerte(lngZeile, 1)
For Spalte = 2 To UBound(arWerte, 2)
ListBox1.List(ListBox1.ListCount - 1, Spalte - 1) = arWerte(lngZeile, Spalte)
Next
End If
End If
End If
End If
End If
Next
End Sub
Für Hilfe wäre ich sehr dankbar!
Viele Grüße
Rudolf