View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Deleting AutoFiltered Rows

Nirmal,

using the intersect with 1 row offset works for me:

Sub FilterDel()
Dim rDel As Range
With Range("A1")
.AutoFilter
.AutoFilter 1, "<A000000000"
With .Worksheet.AutoFilter.Range
On Error Resume Next
Set rDel = Intersect(.Cells.Offset(1), _
.SpecialCells(xlCellTypeVisible))
On Error GoTo 0
If Not rDel Is Nothing Then rDel.EntireRow.Delete
End With
.AutoFilter
.Select
End With
End Sub




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


Nirmal Singh wrote :

I am using the following code to filter a list and delete unwanted
records.

The list has headers on the top row. These are also getting deleted.
How can I do this without deleting the header row?

Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<A000000000",
Operator:= rator:=xlAnd
Selection.SpecialCells(xlCellTypeVisible).Delete
Selection.AutoFilter Range("A1").Select

Nirmal Singh