Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Hiding rows which equal zero sum value

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


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Hiding rows which equal zero sum value

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.Hid den=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])"

--
Cheers,
Shane Devenshire


"Mike" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Hiding rows which equal zero sum value

This was helpful, thank you Shane!

"Mike" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Hiding rows which equal zero sum value

Your very welcome
--

Shane Devenshire


"Mike" wrote:

This was helpful, thank you Shane!

"Mike" wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rows which are equal Neo Excel Discussion (Misc queries) 7 November 6th 06 10:42 PM
Hiding Specific Rows Based on Values in Other Rows Chris Excel Worksheet Functions 1 November 2nd 06 08:21 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
PIVOT TABLE - hiding records with CALCULATED item values equal to Pele Excel Discussion (Misc queries) 0 March 10th 06 04:15 PM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM


All times are GMT +1. The time now is 04:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"