A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Cell Formats & Hiding



 
 
Thread Tools Display Modes
  #1  
Old March 21st, 2010, 06:37 AM posted to microsoft.public.excel.worksheet.functions
Greendistantstar[_2_]
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  
Old March 21st, 2010, 02:50 PM posted to microsoft.public.excel.worksheet.functions
Gary''s Student
external usenet poster
 
Posts: 7,584
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  
Old March 21st, 2010, 03:22 PM posted to microsoft.public.excel.worksheet.functions
Greendistantstar[_2_]
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  
Old March 22nd, 2010, 08:18 AM posted to microsoft.public.excel.worksheet.functions
minyeh
external usenet poster
 
Posts: 29
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.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:50 AM.


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