Solved

Deleting rows of data that are results of Autofilter?

Posted on 2014-02-06
4
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

632 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