ich arbeite erst seit ein paar Tagen mit VBA.
Nun habe ich eine Suchfunktion, mit der ich eine Lieferantenliste durchsuchen kann. Allerdings möchte ich nun bei der Suche das nicht nur nach einem Suchbegriff gesucht wird, sondern mir nur die Ergebnisse angezeigt werden, wo der Status in der Spalte "O" = 1 ist.
Über Hilfe würde ich mich sehr freuen.
Private Sub CommandButton1_Click() ' Suchen
Dim Lieferanten As Workbook, Bereich As Range
Set Lieferanten = Workbooks.Open("Mein Workbook")
ThisWorkbook.Windows(1).Visible = False
Dim rng As Range
Dim strFirst As String
Dim vtmp() As Long
Dim tntC As Integer
If Len(Trim(TextBox13)) = 0 Then Exit Sub
ListBox1.Clear
For IntC = 1 To 11
Controls("TextBox" & IntC) = ""
Next
ReDim vtmp(0)
With Sheets("Stammdaten")
Set rng = .Range("B:B").Find(What:=TextBox13, Lookat:=xlPart)
If Not rng Is Nothing Then
strFirst = rng.Address
Do
If Not (IsNumeric(Application.Match(rng.Row, vtmp, 0))) Then
ReDim Preserve vtmp(UBound(vtmp) + 1)
vtmp(UBound(vtmp)) = rng.Row
ListBox1.AddItem .Cells(rng.Row, 3)
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(rng.Row, 4)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(rng.Row, 7)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(rng.Row, 2)
ListBox1.List(ListBox1.ListCount - 1, 4) = rng.Row
End If
Set rng = .Range("B:B").FindNext(rng)
Loop While Not rng Is Nothing And rng.Address strFirst
End If
End With
If ListBox1.ListCount > 0 Then
ListBox1.ListIndex = 0
Else
ListBox1.AddItem "Kein Eintrag!"
End If
Set rng = Nothing
End Sub