Good day, Gurus.
I have used the snippet of code below many times to delete rows of filtered data. For example, if I want to delete all rows containing "Y" in column F, this code would filter to that criteria, offset it to save the column headings, resize it to avoid deleting the row below the range, then delete the rows. This works beautifully, until I ran into an instance where there were NO "Y"'s in column F. Then it deleted the column headings.
How would I modify the code below to leave the headings in row 1, but delete any other filtered data? (Also, if there's a better way to delete filtered rows but leave headings, I would be interested.)
Thanks in advance for any help you can offer.
Range("F1").AutoFilter Field:=6, Criteria1:="Y"
Set rng = ActiveSheet.AutoFilter.Range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1, _
rng.Columns.Count).Delete Shift:=xlUp
ActiveSheet.AutoFilterMode = False
ActiveSheet.AutoFilterMode = False
Bookmarks