VBA delete rows that have all zeros in Col C thru G

MikeL

Active Member
Joined
Mar 17, 2002
Messages
492
Office Version
  1. 365
Platform
  1. Windows
Hi,
I would like to delete rows in which the values in Col C thru G are all "0". Is there best VBA solution?
Thanks in advance,
Mikel
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Code:
Sub deleterow()
Dim sht As Worksheet
 Set sht = ActiveSheet
Dim LastRow As Long
 LastRow = sht.Cells(sht.Rows.Count, "C").End(xlUp).Row
Dim i As Long
    For i = 1 To LastRow
        If (Cells(i, 3) = 0 And Cells(i, 4) = 0 And Cells(i, 5) = 0 And Cells(i, 6) = 0 And Cells(i, 7) = 0) Then
         Rows(i).Delete
        End If
    Next i
End Sub

Note that an empty cell does not =0
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,918
Messages
6,181,743
Members
453,064
Latest member
robatthe2A

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