Private
Sub
CommandButton1_Click()
Dim
loLetzte
As
Long
, loAnzahl
As
Long
Dim
raZelle
As
Range, strFilterarray
As
String
With
Worksheets(
"Tabelle1"
)
If
.CommandButton1.Caption =
"Ausblenden"
Then
If
.AutoFilterMode
Then
.AutoFilterMode =
False
loLetzte = .Cells(.Rows.Count, 2).
End
(xlUp).Row
For
Each
raZelle
In
.Range(.Cells(3, 4), .Cells(loLetzte, 4))
If
raZelle =
"Finden"
Then
If
strFilterarray = vbNullString
Then
strFilterarray = .Cells(raZelle.Row, 2)
Else
strFilterarray = strFilterarray &
","
& .Cells(raZelle.Row, 2)
End
If
End
If
Next
raZelle
.Range(
"$A$2:$F$"
& loLetzte).AutoFilter Field:=2, Criteria1:=Split(strFilterarray,
","
, -1, _
vbTextCompare), Operator:=xlFilterValues
.Rows(2).Hidden =
True
.CommandButton1.Caption =
"Einblenden"
Exit
Sub
ElseIf
.CommandButton1.Caption =
"Einblenden"
Then
If
.AutoFilterMode
Then
.AutoFilterMode =
False
.Rows(2).Hidden =
False
.CommandButton1.Caption =
"Ausblenden"
End
If
End
With
End
Sub