• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Deleting rows of data that are results of Autofilter?

I am looking for a VBA script that is simple and deletes all visible rows in an autofilter.  I already have the filters applied, I just need to delete everything (except the headers).  I find myself needing this more often..  or better yet, have a visible property that would delete visible if true, or delete all hidden if false.. sort of a tool to use when dealing with autofilters.  Hope this makes sense. -R-
0
RWayneH
Asked:
RWayneH
  • 2
  • 2
1 Solution
 
SteveCommented:
ActiveSheet.Range("$A$1:$Z$65535).SpecialCells _
    (xlCellTypeVisible).EntireRow.Delete

Open in new window

0
 
RWayneHAuthor Commented:
so you are assuming I only have 65K rows?  Does this allow for header row?  need to keep that
0
 
SteveCommented:
ActiveSheet.Range("$A$1:$Z$65535").Offset(1, 0).SpecialCells _
    (xlCellTypeVisible).EntireRow.Delete

Open in new window

This will work with your header rows. And you can either adjust the column and row in the second half or do a count for them and use a variable.

I had left the second quote off the first example....
0
 
RWayneHAuthor Commented:
Thanks. -R-
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now