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

sofas

Well-known Member
Joined
Sep 11, 2022
Messages
559
Office Version
  1. 2021
  2. 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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,223,704
Messages
6,173,984
Members
452,540
Latest member
haasro02

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