I have a little Excel VBA code that autofilters for a criteria and then deletes those that meet that criteria.
Here is the code:
.AutoFilter Field:=8, Criteria1:=Array("*Transfer"), Operator:=xlFilterValues
'Delete the visible rows while keeping the header
If .Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
.Offset(1, 0).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Rows.Delete
This code was working fine until yesterday. For some reason, it stopped deleting all the visible rows. I'm not sure why.
I have tried replacing .Rows.Delete to .EntireRow.Delete but it doesn't work either.
I'm baffled as this was working fine (for weeks now) until yesterday. This code is applied to an automated report that is sent out daily.
Can anyone please tell me what could have gone wrong? It seems to be deleting the top half, then leaving the bottom half of the filtered rows.
Thanks in advance