Hide Rows if all values are zero

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?
 
M

Mike H

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.
 
J

Jef Gorbach

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
 
J

jessica

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top