Ich habe unten aufgeführtes Makro aus dem Forum.
Hier wird über eine Formular-Userform ein Suchbegriff
eingegeben und die gefundenen Werte werden dargestellt.
Kann mir jemand ein Tipp geben, wie ich es anstellen könnte,
die Anzahl der gefundenen Suchbegriffe darzustellen ?!
Private Sub cmdSearch_Click()
Dim rng As Range
Dim sFirst As String
Dim sFind As String
Dim sMod As XlLookAt
Dim n As Integer, i As Integer
Dim arrG
Dim arrL
Dim chkMod
If txtSearch = "" Then Exit Sub
ListBox1.Clear 'Listbox leeren
'Textboxen leeren
For n = 0 To 9
Controls("txt" & n + 1) = ""
Next
n = 0
'Überschriftenzeile
ListBox1.AddItem Sheets("Bestandsprotokoll").Cells(11, 1)
For n = 0 To 9
ListBox1.List(i, n) = Sheets("Bestandsprotokoll").Cells(11, n + 1)
Next
i = i + 1
sFind = txtSearch
sMod = xlWhole
'Suchen
Application.Cursor = xlWait 'Sanduhr
Set rng = Sheets("Bestandsprotokoll").Cells.Find(What:=sFind, LookIn:=xlValues, LookAt:=sMod)
If Not rng Is Nothing Then
sFirst = rng.Address
Do
ListBox1.AddItem Sheets("Bestandsprotokoll").Cells(rng.Row, 1)
For n = 0 To 9
ListBox1.List(i, n) = Sheets("Bestandsprotokoll").Cells(rng.Row, n + 1)
Next
i = i + 1
'weitersuchen bis zur letzten Fundstelle
Set rng = Sheets("Bestandsprotokoll").Cells.FindNext(rng)
Loop While rng.Address <> sFirst
End If
Application.Cursor = xlDefault 'Normal
If ListBox1.ListCount > 1 Then ListBox1.ListIndex = 1
End Sub
Grüße
Günter