Hiding rows which equal zero sum value

M

Mike

I am having difficulty hiding rows with a zero sum value because I have a
break in the sequence. In other words, I'd like to hide the following rows
C8:C88 and C106: C180, but because there is a break in the sequence I am not
sure how to re-write the below Macro. Any assistance would be appreciated.

Sub HideZero()
On Error Resume Next
With Range("D25:D84")
..EntireRow.Hidden = False
For i = 1 To .Rows.Count
If WorksheetFunction.Sum(.Rows(i)) = 0 Then
..Rows(i).EntireRow.Hidden = True
End If
Next i
End With
End Sub
 
S

ShaneDevenshire

Hi Mike,

Here is one way to handle the problem:
Create a dummy column that devides 1 by the average of the row. Hide this
column or not.

Then use the following macro to hide all the rows with a sum of 0"

Sub HideZero()
[J1:J180].SpecialCells(xlCellTypeFormulas,16).EntireRow.Hidden=True
End Sub

In this example J is the column with formulas of the form =1/AVERAGE(A1:I1)
You could also add and remove this dummy column within the macro:
[J1:J180] = "=AVERAGE(RC[-8]:RC[-1])"
 

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