Hi all. I'm back with hat in hand . . . I'm importing four worksheets then I need to cycle through them, apply the same filter and delete rows.
I have the filter working, but I'm not succeeding in moving on to the remaining worksheets. Once it's woking then I know the next step is an error handler to move to the next worksheet. Just in case . . .
TIA as always .
Ron
I have the filter working, but I'm not succeeding in moving on to the remaining worksheets. Once it's woking then I know the next step is an error handler to move to the next worksheet. Just in case . . .
TIA as always .
Code:
Sub m_NoID()
Dim ws As Worksheet
Dim thisws As Worksheet
Dim wb As Workbook
'
Set wb = ActiveWorkbook
Set thisws = ActiveSheet
'
For Each ws In wb.Worksheets
With thisws
LastRow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
.AutoFilterMode = False
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
End If
.Range("$A1", Cells(LastRow, LastCol)).AutoFilter Field:=1, Criteria1:="=", Operator:=xlAnd
With .UsedRange.Offset(1).SpecialCells(xlCellTypeVisible)
If .Rows.Count > 0 Then
.Rows.Delete (xlShiftUp)
End If
End With
.AutoFilter.ShowAllData
Range("A1").Activate
Range("A1").Select
End With
Next
End Sub
Ron