Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Delete Rows Filtered within Auto Filter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gordon - 30 Sep 2006 09:50 GMT
Hi...

I have 3000 records. I want to delete 300 rows that share an auto filtered
value. The problem of course is that when I highlight the block to delete, it
deletes the rows that have't been filtered. Is there a way round this?

Thanks

Gordon...
Norman Jones - 30 Sep 2006 10:38 GMT
Hi Gordon,

Try:

'=============>>
Public Sub Tester()
   Dim WB As Workbook
   Dim SH As Worksheet
   Dim Rng As Range

   Set WB = Workbooks("YourBook.xls") '<<=== CHANGE
   Set SH = WB.Sheets("Sheet1")       '<<=== CHANGE

   On Error Resume Next
   Set Rng = SH.AutoFilter.Range
   Set Rng = Rng.Offset(1).Resize(Rng.Rows.Count - 1)
   Set Rng = Rng.SpecialCells(xlVisible)
   On Error GoTo 0

   If Not Rng Is Nothing Then
       Rng.EntireRow.Delete
   End If
End Sub
'<<=============

You could also perform the operation manually:

Select cells to be deleted
F5 | Special | Visibile cells
Right-click | Delete | Entire row

---
Regards,
Norman

> Hi...
>
[quoted text clipped - 6 lines]
>
> Gordon...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.