ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Rows where all cells = 0 (https://www.excelbanter.com/excel-programming/306662-re-delete-rows-where-all-cells-%3D-0-a.html)

William[_2_]

Delete Rows where all cells = 0
 
Hi SL

Sub test()
Application.ScreenUpdating=False
Dim r As Range, rr As Range, c As Range
Set r = Range("A1:A655")
For Each c In r
If Application.CountIf(Range(c, c.Offset(0, 115)), 0) = 116 Then
If rr Is Nothing Then
Set rr = c
Else
Set rr = Union(rr, c)
End If
End If
Next c
If Not rr Is Nothing Then rr.EntireRow.Delete
Application.ScreenUpdating=True
End Sub

--
XL2002
Regards

William



"SL" wrote in message
...
| Hello
|
| I have a large worksheet - 655 rows & 116 columns. I need to be able to
| search each cell on each row & if all the cells are 0 then delete the row.
| Otherwise, leave the row on the worksheet.
|
| I need to be able to do this within a macro.
|
| Can anyone help??
|
| Thank You
|
| Sonya




All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com