Best Method to Remove Data Rows
Thanks for the code, this is similar to the method I developed that uses a
filter selection and deletes the rest. But although faster than the scan
all rows method it is still quite slow with my worksheet..
But it is an improvement!
--
Cheers
Nigel
wrote in message
oups.com...
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
|