Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Unable to delete rows for only filtered results

The extract below is unable to run when the criteria for the
Autofilter results in the number of rows being in excess of around
15800.


Selection.AutoFilter Field:=6, Criteria1:="="
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete

Even when attempted manually, the "delete rows" function will not work
on a filter and deletes ALL data (both hidden and otherwise). Hence my
subject, the macro won't delete only rows for filtered results where
the filter produces too many rows.

I hope I've made myself understood.
Is there a workaround? Cheers
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Unable to delete rows for only filtered results

i've come across this issue before - there the list seems to large for the
auto-filter to work as expected.

you could write some code to delete hidden rows..

if your table is range named

(UNTESTED)
dim cell as range
for each cell in range("tablename").columns(1).cells
if rows(cell.row).Visible=False then rows(rw).Delete
next

"Richard R" wrote in message
...
The extract below is unable to run when the criteria for the
Autofilter results in the number of rows being in excess of around
15800.


Selection.AutoFilter Field:=6, Criteria1:="="
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete

Even when attempted manually, the "delete rows" function will not work
on a filter and deletes ALL data (both hidden and otherwise). Hence my
subject, the macro won't delete only rows for filtered results where
the filter produces too many rows.

I hope I've made myself understood.
Is there a workaround? Cheers


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Unable to delete rows for only filtered results

Try recording a macro when you select the visible data cells and hit
F5|Special|visible cells only.

Then continue recording when you delete those rows.

'...your code to filter the data

with ActiveSheet
With .AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible). Count = 1 Then
'only headers visible, do nothing
Else
'resize to avoid the header
'and come down one row
.Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible) _
.entirerow.delete
End If
End With
End With



Richard R wrote:

The extract below is unable to run when the criteria for the
Autofilter results in the number of rows being in excess of around
15800.

Selection.AutoFilter Field:=6, Criteria1:="="
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete

Even when attempted manually, the "delete rows" function will not work
on a filter and deletes ALL data (both hidden and otherwise). Hence my
subject, the macro won't delete only rows for filtered results where
the filter produces too many rows.

I hope I've made myself understood.
Is there a workaround? Cheers


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unable to delete rows for only filtered results


hi all,

Dave's suggestion is good in terms of preventing header deletion but is
still fallible in terms of a "by design" limitation of the specialcells
property (see 'here' (http://support.microsoft.com/kb/832293/en-us)).
Here's a link suggesting various workarounds (which you may need help
implementing...):

'Bulk Row Deletion - Fastest method in Excel Programming'
(http://tinyurl.com/nkm5fl)

hth
Rob


--
broro183

Rob Brockett. Always learning & the best way to learn is to
experience...
------------------------------------------------------------------------
broro183's Profile: http://www.thecodecage.com/forumz/member.php?userid=333
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107832

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Unable to delete rows for only filtered results

I couldn't get to the second site you posted.

But I've found that a quick way to delete those rows is to add an extra column
that mimics the rules of the filter -- returning true or false. Then sort by
this column and delete the contiguous range (either true or false).

If I need to resort when I'm done, I make sure that there is a nice key or add a
second column that provides the nice sort order.

(and then remove those columns when done.)

broro183 wrote:

hi all,

Dave's suggestion is good in terms of preventing header deletion but is
still fallible in terms of a "by design" limitation of the specialcells
property (see 'here' (http://support.microsoft.com/kb/832293/en-us)).
Here's a link suggesting various workarounds (which you may need help
implementing...):

'Bulk Row Deletion - Fastest method in Excel Programming'
(http://tinyurl.com/nkm5fl)

hth
Rob

--
broro183

Rob Brockett. Always learning & the best way to learn is to
experience...
------------------------------------------------------------------------
broro183's Profile: http://www.thecodecage.com/forumz/member.php?userid=333
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107832


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unable to delete rows for only filtered results


hi Dave,

Nice work around :)

I think the second link provides an interesting read so here are some
alternative links to the same thread:

Shortened version of previous link: 'Bulk Row Deletion - Fastest method
in Excel Programming' (http://tinyurl.com/lsmyhh)

Same thread on a different server: 'Excel Bulk Row Deletion - Fastest
method' (http://www.databaseforum.info/16/8/6...0964c7cb0.html)

Link to one post in the thread: 'microsoft.public.excel.programming:
Bulk Row Deletion - Fastest method' (http://tinyurl.com/kq9uba)

or straight from my search - any of the links shown by: 'specialcells
excel limit\"bulk row deletion\" \"fastest method\" - Google Search'
(http://tinyurl.com/lljkg9)

hopefully one of these links works :)
Rob


--
broro183

Rob Brockett. Always learning & the best way to learn is to
experience...
------------------------------------------------------------------------
broro183's Profile: http://www.thecodecage.com/forumz/member.php?userid=333
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107832

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Unable to delete rows for only filtered results

That first suggestion by quartz suffers the same problem if there are too many
areas.

The suggestion by Stephen Bullen is about the same as I suggested.



broro183 wrote:

hi Dave,

Nice work around :)

I think the second link provides an interesting read so here are some
alternative links to the same thread:

Shortened version of previous link: 'Bulk Row Deletion - Fastest method
in Excel Programming' (http://tinyurl.com/lsmyhh)

Same thread on a different server: 'Excel Bulk Row Deletion - Fastest
method' (http://www.databaseforum.info/16/8/6...0964c7cb0.html)

Link to one post in the thread: 'microsoft.public.excel.programming:
Bulk Row Deletion - Fastest method' (http://tinyurl.com/kq9uba)

or straight from my search - any of the links shown by: 'specialcells
excel limit\"bulk row deletion\" \"fastest method\" - Google Search'
(http://tinyurl.com/lljkg9)

hopefully one of these links works :)
Rob

--
broro183

Rob Brockett. Always learning & the best way to learn is to
experience...
------------------------------------------------------------------------
broro183's Profile: http://www.thecodecage.com/forumz/member.php?userid=333
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107832


--

Dave Peterson
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
COPY PASTE with FILTER copies anti-filtered results as hidden rows BlueWolverine Excel Programming 2 February 16th 09 05:33 PM
Delete all filtered rows from a macro? Joe M Excel Programming 1 February 3rd 09 10:46 PM
cannot delete filtered rows in excel 2007 Cindy E Excel Discussion (Misc queries) 3 October 6th 08 07:09 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
Excel - How do I delete filtered out rows? rook Excel Discussion (Misc queries) 2 November 30th 05 10:45 PM


All times are GMT +1. The time now is 05:17 PM.

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"