Overview:
I have 2 macros, one filters the data and the second deletes the visible rows below the header rows (header rows 1-12).
2 Questions:
1) How do I best combine these into a single macro? 2) How do I get the second one to work properly?
I receive the
Run Time Error 1004: Method 'Range' of object '_worksheet' failed
on the Delete() macro line:
Set rng = .Range("A12:A" & LastRow).SpecialCells(xlCellTypeVisible)
I have also tried:
Set rng = .Range("A12:A" & LastRow).SpecialCells(xlCellTypeVisible).cells
Sub Filter()
'filter and delete rows that have AW as FALSE
For Each sht In ThisWorkbook.Worksheets
sht.Range("A12:AW12").autofilter Field:=49, Criteria1:="FALSE"
Next sht
End Sub
Sub Delete()
Dim sht As Worksheet, rng As Range, lastRow As Long
Set sht = Worksheets("Sheet1")
With sht
lastRow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set rng = .Range("A12:A" & LastRow).SpecialCells(xlCellTypeVisible)
rng.EntireRow.Delete
.AutoFilterMode = False
End With
End Sub