Ich möchte die gleiche Werten in Spalte B filtern, wo in der Spalte C den Wert mit Z anfängt.
Etwa So (siehe Excel)
https://www.herber.de/bbs/user/120166.xlsx
LG Pascal
Sub FilterSpezial()
Dim lastRow As Long, i As Long, a As Long
Dim strText As String
Dim strZiffer As String
Dim rngSearch As Range
lastRow = ActiveSheet.Range("A:C").Find("*", searchdirection:=xlPrevious).Row
strText = "ZULA_HU_RESERVE"
Set rngSearch = Range("A2:A" & lastRow)
Application.ScreenUpdating = False
ActiveSheet.Rows("2:" & lastRow).Hidden = True
For i = 2 To lastRow
If Range("C" & i) = strText Then
strZiffer = Range("A" & i)
If Application.CountIf(rngSearch, strZiffer) > 1 Then
For a = 2 To lastRow
If Range("A" & a) = strZiffer Then
Rows(a).Hidden = False
End If
Next a
Rows(i).Hidden = False
End If
End If
Next i
Set rngSearch = Nothing
End Sub
Sub FilterAufheben()
Dim lastRow As Long
lastRow = ActiveSheet.Range("A:C").Find("*", searchdirection:=xlPrevious).Row
ActiveSheet.Rows("2:" & lastRow).Hidden = False
End Sub
https://www.herber.de/bbs/user/120182.xls
Dim loLetzte As Long
With Worksheets("Tabelle1")
If .CommandButton1.Caption = "Filtern" Then
loLetzte = .Cells(.Rows.Count, 3).End(xlUp).Row
.Range("A1:D" & loLetzte).AutoFilter Field:=3, Criteria1:="=Z*"
.CommandButton1.Caption = "Alles Anzeigen"
ElseIf .CommandButton1.Caption = "Alles Anzeigen" Then
.AutoFilter.ShowAllData
If .AutoFilterMode Then .AutoFilterMode = False
.CommandButton1.Caption = "Filtern"
End If
End With
4. Im Tabellenblatt den Entwurfsmodus des CommandButton ausschalten
Option Explicit
Sub ccc()
Dim X As Long, strC As String, strShow As String
strC = "ZULA_HU_RESERVE"
For X = 1 To Cells(Rows.Count, 1).End(xlUp)
If Cells(X, 3) = strC Then
If WorksheetFunction.CountIf(Columns("A"), Cells(X, 1)) > 1 Then
strShow = strShow & "|" & Cells(X, 1)
End If
End If
Next
If Len(strShow) > 0 Then
Range("A1").AutoFilter
Range("A1").AutoFilter 1, Array(Split(Mid(strShow, 2), "|")), 7
Else
MsgBox "nix"
End If
End Sub