ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Rows Filtered within Auto Filter (https://www.excelbanter.com/excel-programming/374055-delete-rows-filtered-within-auto-filter.html)

Gordon[_2_]

Delete Rows Filtered within Auto Filter
 
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

Delete Rows Filtered within Auto Filter
 
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



"Gordon" wrote in message
...
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...





All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com