View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Delete row macro

your welcome

"AT" wrote:

Thanks.
Worked fine!

"Mike H" wrote:

Hi,

The logic fior this interprets as
If B1 = B2 And C1 = C2 And D1 = 0 Then
delete the row so try this

Sub delete_Me()
Lastrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
For x = Lastrow To 1 Step -1
If Range("B" & (x)) = Range("B" & (x + 1)) _
And Range("C" & (x)) = Range("C" & (x + 1)) _
And (Range("D" & (x))) = "0" Then
Rows(x).Delete
End If
Next
End Sub

Mike



"AT" wrote:

Hi,
I need a macro that can delete certain rows as follows:
If B(X)=B(X+1) AND C(X)=C(X+1) AND D(X) =0 THEN
Delete row(X)
Else do nothing

Is it possible?