Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can you create a macro to hide rows with zero values?

I am trying to automate emailing of financial reports to managers in our
Organization. I have one spreadsheet template with every account listed.
However, not every manager has amount in every line, and the report is pretty
long with every account listed.

I would like to create a macro to look at the a range of values in each row
of the report, and then hide any rows which have a zero value in each cell in
the range.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Can you create a macro to hide rows with zero values?

Hi natrujillo12

You can use this to hide all the cells with a 0 in column A in the first 100 rows of the active sheet.

Sub UnionExample()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
Dim rng As Range

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 100
For Lrow = StartRow To EndRow Step 1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell
ElseIf .Cells(Lrow, "A").Value = "0" Then
If rng Is Nothing Then
Set rng = .Cells(Lrow, "A")
Else
Set rng = Application.Union(rng, .Cells(Lrow, "A"))
End If
End If
Next
End With
'hide all rows in one time
If Not rng Is Nothing Then rng.EntireRow.Hidden = True

With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"natrujillo12" wrote in message ...
I am trying to automate emailing of financial reports to managers in our
Organization. I have one spreadsheet template with every account listed.
However, not every manager has amount in every line, and the report is pretty
long with every account listed.

I would like to create a macro to look at the a range of values in each row
of the report, and then hide any rows which have a zero value in each cell in
the range.




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
Macro to hide rows with zero values in columns K Dawson Excel Discussion (Misc queries) 2 March 23rd 10 03:00 PM
Macro code to hide rows and not calculate hidden rows bradmcq Excel Discussion (Misc queries) 0 September 1st 09 12:38 AM
Using Macro to Hide Rows with Certain Values Gap from Target[_2_] Excel Discussion (Misc queries) 2 July 17th 09 12:57 PM
Automatically hide rows with no values Momof2 Excel Discussion (Misc queries) 1 September 19th 08 12:25 AM
Can anyone tell me how to hide rows that have 0 values and text. Aussie Charts and Charting in Excel 2 April 13th 06 10:57 AM


All times are GMT +1. The time now is 08:03 AM.

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

About Us

"It's about Microsoft Excel"