Deleting rows with multiple columns that = 0

cutemeatball

New Member
Joined
Jun 13, 2022
Messages
20
Office Version
  1. 365
Platform
  1. Windows
Hello! So this macro works and deletes the rows where specific columns equal 0. But the problem is that it deletes my first 4 rows which are empty spaces throughout. Can anyone assist on this?

Thanks!


VBA Code:
Sub delete3zerocolumns()

   Dim lr As Long, i As Long
   Dim ws As Worksheet
   
   For Each ws In Worksheets
   
      With ws
      
         lr = .Cells(.Rows.Count, "I").End(xlUp).Row
         
         For i = lr To 1 Step -1
         
            If .Cells(i, "Q") = 0 And .Cells(i, "R") = 0 And .Cells(i, "S") = 0 Then
               .Rows(i).Delete
            End If
         
         Next i

      End With
      
   Next ws
   
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try this:
Instead of this:
For i = lr To 1 Step -1

Try this:

For i = lr To 4 Step -1
 
Upvote 0
Solution

Forum statistics

Threads
1,215,042
Messages
6,122,810
Members
449,095
Latest member
m_smith_solihull

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