Thread: Deleting Rows
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Pete McCosh[_5_] Pete McCosh[_5_] is offline
external usenet poster
 
Posts: 59
Default Deleting Rows

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


-----Original Message-----
Please help with some code for the following .....

I need to create a loop to scan down a column and if the

contents of a
cell are say "D" then delete this row and go onto the

next entry.

Thanks