VBA to delete rows in filtered table
Posted on 2012-03-13
Attached is some code I'm using to Filter one column in a Table and then delete the visible rows. I had difficulty with Selection.EntireRow.Delete but have replaced it with RngToDelete.Delete.
My problem is that the code stops and asks if I want to "Delete Entire Sheet Row?". I click "Yes" and it's fine. How can I have the code eliminate that step as well so it runs from start to finish without stopping?
This is very likely a no brainer for all of you. My attempt at code is below. Thank you!
Dim RngToDelete As Range
ActiveSheet.ListObjects("TblFTE").Range.AutoFilter Field:=10, Criteria1:= _
Array("Business Development", "G&A", "Marketing", "R&D", "Solutions", "Support"), _
Set RngToDelete = Selection.SpecialCells(xlCellTypeVisible)