Deleting Rows

P

Pete McCosh

Simon,

the following piece of code can be amended easily to
handle this sort of thing. This version deletes empty rows
in a range. To amend for your example (and assuming your
values are in column A), change the If...Then line to

If Cells(r,1).value = "D" Then

Cheers, Pete

Sub DeleteEmptyRows()

Dim LastRow As Integer
Dim r As Integer
Application.ScreenUpdating = False

LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

For r = LastRow To 1 Step -1
If Application.WorksheetFunction.CountA(Rows(r)) = 0 Then
Rows(r).Delete
End If
Next r

Application.ScreenUpdating = True
End Sub
 
Top