L
Les
Hi, i have code below that filters field 10 and then deletes the
filterd rows that are showing; this works great, but i have to filter
another field afterwards and have tried to use the same code, but it
then deletes everything ??
Can somebody tell me why..
Public Sub FilterCreatedBy()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Set WB = ActiveWorkbook
Set SH = ActiveSheet
Rows("1:1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="=*za-t-m-**",
Operator:=xlAnd
On Error Resume Next
Set Rng = SH.AutoFilter.Range
Set Rng = Rng.Offset(1).Resize(Rng.Rows.Count - 1)
Set Rng = Rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not Rng Is Nothing Then
Rng.EntireRow.Delete
End If
Selection.AutoFilter Field:=10
End Sub
filterd rows that are showing; this works great, but i have to filter
another field afterwards and have tried to use the same code, but it
then deletes everything ??
Can somebody tell me why..
Public Sub FilterCreatedBy()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Set WB = ActiveWorkbook
Set SH = ActiveSheet
Rows("1:1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="=*za-t-m-**",
Operator:=xlAnd
On Error Resume Next
Set Rng = SH.AutoFilter.Range
Set Rng = Rng.Offset(1).Resize(Rng.Rows.Count - 1)
Set Rng = Rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not Rng Is Nothing Then
Rng.EntireRow.Delete
End If
Selection.AutoFilter Field:=10
End Sub