delete row based on values....almost there

Skidood

New Member
Joined
Jan 1, 2018
Messages
35
OK now I need to detect when the data in any 2 adjacent cells in columns B and C are both equal to zero, and then delete that row.

For example, below I would want to have row 35 deleted.



Excel 2010 32 bit
BCD

<tbody>
[TD="align: center"]29[/TD]
[TD="align: center"]1:53:30[/TD]
[TD="align: center"]113.50[/TD]
[TD="align: center"]0.500[/TD]

[TD="align: center"]30[/TD]
[TD="align: center"]1:54:00[/TD]
[TD="align: center"]114.00[/TD]
[TD="align: center"]0.500[/TD]

[TD="align: center"]31[/TD]
[TD="align: center"]1:54:30[/TD]
[TD="align: center"]114.50[/TD]
[TD="align: center"]0.500[/TD]

[TD="align: center"]32[/TD]
[TD="align: center"]1:55:00[/TD]
[TD="align: center"]115.00[/TD]
[TD="align: center"]0.500[/TD]

[TD="align: center"]33[/TD]
[TD="align: center"]1:55:30[/TD]
[TD="align: center"]115.50[/TD]
[TD="align: center"]0.500[/TD]

[TD="align: center"]34[/TD]
[TD="align: center"]1:56:00[/TD]
[TD="align: center"]116.00[/TD]
[TD="align: center"]0.500[/TD]

[TD="align: center"]35[/TD]
[TD="align: center"]0:00:00[/TD]
[TD="align: center"]0.00[/TD]
[TD="align: center"]1324.000[/TD]

</tbody>


I already have a macro that deletes rows but don't know how to add to it:

Sub CommandButton1_Click()

With Columns(77)
On Error Resume Next
.SpecialCells(xlFormulas, xlLogical).EntireRow.Delete
.SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
On Error GoTo 0

End With

End Sub
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Using your example shown, this code should work for you

Code:
Option Explicit


Sub DelRow()
    Dim lr As Long
    Dim i As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Application.ScreenUpdating = False
    For i = lr To 1 Step -1
        If Range("B" & i) = 0 Then
            If Range("C" & i) = 0 Then
                Range("B" & i).EntireRow.Delete
            End If
        End If
    Next i
    Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top