Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming |