Delete rows when checking that there is no zero value in one of the columns

sofas

Active Member
Joined
Sep 11, 2022
Messages
469
Office Version
  1. 2019
Platform
  1. Windows
Hello, I want a code that deletes rows that do not contain a zero value in columns A, B, C, and D. That is, I might try to filter the data and check if there is a 0 in one of the rows.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi,

I think this should work for you:
VBA Code:
Sub test()
  Dim i As Long, lRow As Long
  lRow = Cells(Rows.Count, "A").End(xlUp).Row
  With Application
  .ScreenUpdating = False
  For i = lRow To 1 Step -1
    If IsError(.Match(0, Range("A" & i & ":D" & i), 0)) Then
      Rows(i).EntireRow.Delete
    End If
  Next
  .ScreenUpdating = True
  End With
End Sub
 
Upvote 0
Solution
Hi,

I think this should work for you:
VBA Code:
Sub test()
  Dim i As Long, lRow As Long
  lRow = Cells(Rows.Count, "A").End(xlUp).Row
  With Application
  .ScreenUpdating = False
  For i = lRow To 1 Step -1
    If IsError(.Match(0, Range("A" & i & ":D" & i), 0)) Then
      Rows(i).EntireRow.Delete
    End If
  Next
  .ScreenUpdating = True
  End With
End Sub
Great, this is what I'm looking for, thank you
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,966
Members
449,094
Latest member
Anshu121

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