Solved

Deleting rows of data that are results of Autofilter?

Posted on 2014-02-06
4
198 Views
Last Modified: 2014-02-08
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
Comment
Question by:RWayneH
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Steve
ID: 39840348
ActiveSheet.Range("$A$1:$Z$65535).SpecialCells _
    (xlCellTypeVisible).EntireRow.Delete

Open in new window

0
 

Author Comment

by:RWayneH
ID: 39840708
so you are assuming I only have 65K rows?  Does this allow for header row?  need to keep that
0
 
LVL 7

Accepted Solution

by:
Steve earned 500 total points
ID: 39840858
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
 

Author Closing Comment

by:RWayneH
ID: 39844073
Thanks. -R-
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question