LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting AutoFiltered Rows

If all rows are visible then that would be the expected/desired behavior -
all rows met the critiera (or you could check that there is actually
criteria applied).

In the case of no rows meeting the criteria (only the header row visible),
that has bitten me several times and I usually put in code to test for that.

In the mixed case, that is the desired behavior.
--
Regards,
Tom Ogilvy

"keepITcool" wrote in message
t.com...
Tom,

Done some more testing...

If autofilter is active the delete method will delete:
specified rows if ALL those rows are either visible or hidden,
but if the specified range contains a mix of hidden and visible rows,
then only the visible rows will be deleted.



Sub test()
Fill
[3:9].Delete
[a1].AutoFilter

MsgBox "Deleted 3:9" _
& vbLf & "Mixed visibility = Visible rows 4,6,8 deleted"

Fill
[3:3,5:5,7:7,9:9].Delete
[a1].AutoFilter
MsgBox "Deleted 3,5,7,9" _
& vbLf & "All rows hidden = specified rows deleted"

Fill
[3:3,5:5,7:7,9:10].Delete
[a1].AutoFilter
MsgBox "Deleted 3,5,7,9:10" _
& vbLf & "Mixed = only the visible row(10) in spec deleted"

End Sub

Sub Fill()
Cells.Clear
[a1:b1] = Array("Number", "Even")
[a2:a11] = [ROW(2:11)]
[b2:b11] = [INDEX(MOD(ROW(2:11),2)=0,0,1)]
[a1].AutoFilter
[a1].AutoFilter 2, True
End Sub




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote :

ActiveSheet.AutoFilter.Range.EntireRow.Delete
Activesheet.Range(Activesheet.Autofilter.Range.Add ress).EntireRow.Dele
te

For me (and as I would expect)
Both worked the same in Excel 2002
Only the visible rows (including the header row) were deleted.





 
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
rogue rows appear in autofiltered sort dmich Excel Discussion (Misc queries) 0 January 11th 09 04:49 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Copy Autofiltered rows to another workbook using macro ashish128 Excel Discussion (Misc queries) 2 July 27th 07 01:25 PM
How to plot only visible autofiltered rows in a data list Craig Charts and Charting in Excel 1 June 28th 05 08:38 PM
Count Autofiltered Rows? simsjr Excel Programming 1 January 26th 05 11:21 PM


All times are GMT +1. The time now is 12:20 PM.

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

About Us

"It's about Microsoft Excel"