ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete row macro (https://www.excelbanter.com/excel-programming/407873-delete-row-macro.html)

AT

Delete row macro
 
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?


Mike H

Delete row macro
 
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?


AT

Delete row macro
 
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?


Mike H

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?



All times are GMT +1. The time now is 10:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com