Macro - Delete Visible Filtered Rows

acolmer

New Member
Hi all,

Happy Friday. I'm trying to record a macro that filters a table to any rows with a "D" in the designated row and then deletes the visible rows, unfiltering the table before ending the macro.

I am using the below but it is failing on the "Selection.EntireRow.Delete" command - is anyone able to recommend anything?

Thanks for your help in advance!



Sub Delete()
'
' Delete Macro
'


'
ActiveSheet.Range("$C$5:$T$3456").AutoFilter Field:=1, Criteria1:="<>"
Range("C786").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Rows("1:8").EntireRow.Select
ActiveCell.Activate
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete
ActiveSheet.Range("$C$5:$T$3453").AutoFilter Field:=1
End Sub
 

DanteAmor

Well-known Member
Try this
I guess the headings are in row 5

Code:
Sub Delete()
  Range("C5:T" & Range("C" & Rows.Count).End(xlUp).Row).AutoFilter Field:=1, Criteria1:="<>"
  ActiveSheet.AutoFilter.Range.Offset(1).EntireRow.Delete
  ActiveSheet.ShowAllData
End Sub
 

acolmer

New Member
Thanks - apologies if this is an overly stupid question but I am a newbie - at what point to I paste this?
 

Some videos you may like

This Week's Hot Topics

Top