Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Deleting rows which match filter

I want to delete all the rows which match a selected filter. Currently I
have:

Selection.AutoFilter Field:=6, Criteria1:="0"
Rows("2:1517").Delete Shift:=xlUp

It works great as long as I don't have more than 1517 rows. How do I change
it so I specify all data rows in the worksheet (same as an end,down would
do)?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting rows which match filter

Selection.AutoFilter Field:=6, Criteria1:="0"
set rng = Activesheet.Autofilter.Range
set rng = rng.offset(1,0).Resize(rng.rows.count-1)
rng.Delete Shift:=xlup

we need to shift down one row so we don't delete the header row.

--
Regards,
Tom Ogilvy


Fred Smith wrote in message
...
I want to delete all the rows which match a selected filter. Currently I
have:

Selection.AutoFilter Field:=6, Criteria1:="0"
Rows("2:1517").Delete Shift:=xlUp

It works great as long as I don't have more than 1517 rows. How do I

change
it so I specify all data rows in the worksheet (same as an end,down would
do)?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Deleting rows which match filter

Fred Smith,
Try,
Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row) _
..SpecialCells(xlVisible).Delete Shift:=xlUp

HTH
Cecil

"Fred Smith" wrote in message
...
I want to delete all the rows which match a selected filter. Currently I
have:

Selection.AutoFilter Field:=6, Criteria1:="0"
Rows("2:1517").Delete Shift:=xlUp

It works great as long as I don't have more than 1517 rows. How do I

change
it so I specify all data rows in the worksheet (same as an end,down would
do)?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Data filter and deleting rows in visual basic Ruben Excel Discussion (Misc queries) 0 August 24th 08 08:38 PM
Filter PivotTable dropdown items to match report filter Catherine D Excel Discussion (Misc queries) 1 August 16th 08 12:12 AM
Deleting rows in filter mode - Excel 2007 Michael New Users to Excel 0 April 17th 08 10:56 PM


All times are GMT +1. The time now is 07:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"