Solved

Deleting rows of data that are results of Autofilter?

Posted on 2014-02-06
4
195 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now