View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
[email protected] raymond.allan@bench.com is offline
external usenet poster
 
Posts: 24
Default Best Method to Remove Data Rows


Filter your data for the rows you want to delete and then run the
following code

Sub Remove_Data()

Dim rng As Range
Dim rng2 As Range

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With

If rng2 Is Nothing Then
' Do Nothing
Else ' Delete the rows
Set rng = ActiveSheet.AutoFilter.Range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Delete
End If

ActiveSheet.AutoFilterMode = False

End Sub