I want to delete all rows in the filtered range except the first visible row after the header.
For example,
This is a sample table:
I want to delete all the filtered rows of apple Except row number 3 which is the first visible filtered row.
I have tried below code :
Sub Filter()
Dim cl, rng As Range
Range("A1").AutoFilter Field:=1, Criteria1:="Apple"
Set rng = Range("A2:A7")
For Each cl In rng.SpecialCells(xlCellTypeVisible)
cl.EntireRow.Delete
Next cl
End Sub
The problem with this code is that it deletes all the filtered rows. How to specify not to delete the first visible row