Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Cell Formats & Hiding

Hi

I have a worksheet I use frequently, where some cells have zero values.

For presentation's sake, I hide rows where the value is zero, and this I do manually.

The zero vales can and do change.

How do I write a macro to hide cells with zero values?

TIA

GDS


"Let's roll!"
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Cell Formats & Hiding

Give this a try:

Sub HideZeroRows()
Dim r As Range, nLastRow As Long, r2 As Range
Dim n1 As Long, n2 As Long
Dim f As WorksheetFunction
Set f = Application.WorksheetFunction
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
Cells.EntireRow.Hidden = False
For i = 1 To nLastRow
Set r2 = Rows(i)
n1 = f.CountIf(r2, 0) + f.CountIf(r2, "")
If n1 = Columns.Count Then
Rows(i).Hidden = True
End If
Next
End Sub

--
Gary''s Student - gsnu201001


"Greendistantstar" wrote:

Hi

I have a worksheet I use frequently, where some cells have zero values.

For presentation's sake, I hide rows where the value is zero, and this I do manually.

The zero vales can and do change.

How do I write a macro to hide cells with zero values?

TIA

GDS


"Let's roll!"
.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Cell Formats & Hiding

Gary''s Student wrote:
Give this a try:

Sub HideZeroRows()
Dim r As Range, nLastRow As Long, r2 As Range
Dim n1 As Long, n2 As Long
Dim f As WorksheetFunction
Set f = Application.WorksheetFunction
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
Cells.EntireRow.Hidden = False
For i = 1 To nLastRow
Set r2 = Rows(i)
n1 = f.CountIf(r2, 0) + f.CountIf(r2, "")
If n1 = Columns.Count Then
Rows(i).Hidden = True
End If
Next
End Sub


Thanks. I'll trying running this later today.

GDS

"Let's roll!"
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 30
Default Cell Formats & Hiding

On Mar 21, 11:22*pm, Greendistantstar
wrote:
Gary''s Student wrote:
Give this a try:


Sub HideZeroRows()
Dim r As Range, nLastRow As Long, r2 As Range
Dim n1 As Long, n2 As Long
Dim f As WorksheetFunction
Set f = Application.WorksheetFunction
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
Cells.EntireRow.Hidden = False
For i = 1 To nLastRow
* * Set r2 = Rows(i)
* * n1 = f.CountIf(r2, 0) + f.CountIf(r2, "")
* * If n1 = Columns.Count Then
* * * * * *Rows(i).Hidden = True
* * End If
Next
End Sub


Thanks. I'll trying running this later today.

GDS

"Let's roll!"- Hide quoted text -

- Show quoted text -


i'll prefer using autofilter function.
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
Hiding a row when a cell has a value Souljacked Excel Discussion (Misc queries) 1 February 2nd 10 08:55 PM
Hiding a cell with a formula. BMoran Excel Worksheet Functions 2 November 12th 09 06:31 PM
hiding formula in cell ljgent Excel Discussion (Misc queries) 2 July 9th 09 05:36 PM
hiding 1 cell duckie Excel Discussion (Misc queries) 2 October 5th 07 03:18 PM
hiding a value in a single cell Bill Excel Worksheet Functions 1 February 11th 07 11:58 PM


All times are GMT +1. The time now is 08:52 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"