PC Review


Reply
Thread Tools Rate Thread

Automatically Hide rows with a value of zero

 
 
tim@beacondevelopment.com
Guest
Posts: n/a
 
      20th Jun 2007
I would like to get a VBA code to hide all rows for a given range that
have a value of zero in column z. Column z has an IF statement
formula. I would like to have the code activate automatically, so if
the value in column z changes to zero the row would be hidden or vice
versa. I have a macor that will run and hide them but I have to run
the macro - I'd like it to happen automatically.

Thanks,

 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      20th Jun 2007
Put the following in worksheet code:

Private Sub Worksheet_Calculate()
Application.EnableEvents = False
Set r = Intersect(Range("Z:Z"), ActiveSheet.UsedRange)
For Each rr In r
If rr.Value = 0 Then
rr.EntireRow.Hidden = True
End If
Next
Application.EnableEvents = True
End Sub

--
Gary''s Student - gsnu200731


"(E-Mail Removed)" wrote:

> I would like to get a VBA code to hide all rows for a given range that
> have a value of zero in column z. Column z has an IF statement
> formula. I would like to have the code activate automatically, so if
> the value in column z changes to zero the row would be hidden or vice
> versa. I have a macor that will run and hide them but I have to run
> the macro - I'd like it to happen automatically.
>
> Thanks,
>
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      20th Jun 2007
Might do better with this that checks for formula cells and hides just those
rows with 0 in Z and not all blank rows in used range.

Private Sub Worksheet_Calculate()
On Error GoTo stoppit
Application.EnableEvents = False
With ActiveSheet.UsedRange
.Rows.Hidden = False
For Each cell In .Columns(26).SpecialCells(xlCellTypeFormulas)
If cell.Text = "" Or cell.Value = 0 Then _
cell.EntireRow.Hidden = True
Next cell
End With
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Wed, 20 Jun 2007 10:14:01 -0700, Gary''s Student
<(E-Mail Removed)> wrote:

>Put the following in worksheet code:
>
>Private Sub Worksheet_Calculate()
>Application.EnableEvents = False
>Set r = Intersect(Range("Z:Z"), ActiveSheet.UsedRange)
>For Each rr In r
> If rr.Value = 0 Then
> rr.EntireRow.Hidden = True
> End If
>Next
>Application.EnableEvents = True
>End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically Hide Rows Tracy Microsoft Excel Worksheet Functions 10 13th Nov 2008 09:18 PM
Automatically add/hide rows wx4usa@gmail.com Microsoft Excel Discussion 13 29th Dec 2006 02:44 PM
automatically hide rows with zero value =?Utf-8?B?aGZjMjE=?= Microsoft Excel Worksheet Functions 1 23rd Jan 2006 07:33 PM
Hide rows automatically =?Utf-8?B?a2lt?= Microsoft Excel Misc 1 14th Sep 2005 02:23 PM
How do I automatically hide rows =?Utf-8?B?Um9iUm95?= Microsoft Excel Misc 8 2nd Feb 2005 01:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:15 PM.