Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AT AT is offline
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.programming
AT AT is offline
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:16 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:54 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM


All times are GMT +1. The time now is 04:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"