Hide Rows if all values are zero

  • Thread starter Thread starter jessica
  • Start date Start date
J

jessica

I am trying to write a macro that will hide a row if certain cells in that
row are all zero. I want the macro to apply to all rows in the worksheet.
Can anyone help?
 
Hi,
I am trying to write a macro that will hide a row if certain cells in that
row are all zero

Would you like to share with us which cells in a row they are?
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
Dont have a copy of Excel handy to test, but sounds like you want
something along the lines of:

Sub untested()
Dim myrange As Range
For row = 2 to Range("A65536").End(Xlup).Row
myrange = Range(Cells(row,"A"),Cells(row,"d"))
If Application.WorksheetFunction.Sum(myrange) = 0 Then
myrange.EntireRow.Delete
Next
End Sub
 
Yes, the cells are in columns F, H, J, L, N, P, R, T, V, X, and Z of each row
(10-131) on a sheet.
 
Back
Top