Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel 2007 - Deleting Rows from a Table with AutoFilter

Given a Table1 that looks like this:
column1 column2
1 USA
2
3 USA
4 USA
5
6 UK
7 Germany
8
9 Finland
10 Russia
11 USA
12 Japan


And using Excel 2007, I need to delete all rows who have a column2 cell who
value is blank.
Sounds simple, googled a number of examples that suggest to
AutoFilter the list with an "=" criteria to match blanks:
Then using
SpecialCells(xlCellTypeVisible).EntireRow.Delete

And this code:
Sub Macro1()
Dim table As ListObject
Set table = ActiveSheet.ListObjects("Table1")
table.Range.Select
Selection.AutoFilter Field:=2, Criteria1:="="
Selection.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delet e
End Sub

I get this error:
Run-time error '1004': Delete method of Range class failed.

Any Ideas on what I am doing wrong?
TIA
Tom




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel 2007 - Deleting Rows from a Table with AutoFilter

See this page for a example
http://www.rondebruin.nl/delete.htm


Try this one without filter first
http://www.rondebruin.nl/specialcells.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"TomC" wrote in message ...
Given a Table1 that looks like this:
column1 column2
1 USA
2
3 USA
4 USA
5
6 UK
7 Germany
8
9 Finland
10 Russia
11 USA
12 Japan


And using Excel 2007, I need to delete all rows who have a column2 cell who
value is blank.
Sounds simple, googled a number of examples that suggest to
AutoFilter the list with an "=" criteria to match blanks:
Then using
SpecialCells(xlCellTypeVisible).EntireRow.Delete

And this code:
Sub Macro1()
Dim table As ListObject
Set table = ActiveSheet.ListObjects("Table1")
table.Range.Select
Selection.AutoFilter Field:=2, Criteria1:="="
Selection.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delet e
End Sub

I get this error:
Run-time error '1004': Delete method of Range class failed.

Any Ideas on what I am doing wrong?
TIA
Tom




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
Excel 2007 Autofilter deleting unfiltered Data Chris Excel Worksheet Functions 0 May 15th 08 11:06 PM
Deleting rows in Excel 2007 using filters Bentam7 Excel Discussion (Misc queries) 1 March 26th 08 11:50 AM
Deleting specific rows after an autofilter forbrowsing Excel Programming 1 January 16th 07 05:55 PM
Deleting rows in a range using Autofilter Connie Excel Discussion (Misc queries) 3 October 17th 06 01:47 PM
Generalising Deleting Rows after AUTOFILTER jason Excel Programming 3 November 5th 04 02:17 PM


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

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"