LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Automatically hide rows with 0 value....faster?

Hi,

I used this code in VB to automatically hide rows that have formulas
resulting in a value of zero:

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

Then I decided that I would rather have it so I can hide or unhide manually,
so I created macros with hide and show buttons with this code:
Sub Hide()
On Error GoTo stoppit
Application.EnableEvents = False
With ActiveSheet.UsedRange
.Rows.Hidden = False
For Each cell In .Columns(30).SpecialCells(xlCellTypeFormulas)
If cell.Text = "" Or cell.Value = 0 Then _
cell.EntireRow.Hidden = True
Next cell
End With
stoppit:
Application.EnableEvents = True
End Sub
------------------------------
Sub Show()
On Error GoTo stoppit
Application.EnableEvents = False
With ActiveSheet.UsedRange
.Rows.Hidden = False
For Each cell In .Columns(30).SpecialCells(xlCellTypeFormulas)
If cell.Text = "" Or cell.Value = 0 Then _
cell.EntireRow.Hidden = False
Next cell
End With
stoppit:
Application.EnableEvents = True
End Sub

With the macros, this runs slower than desired. Is there a way to keep it
in VB and still allow a way to use the hide / show buttons, so it's not
automatic? It runs much faster thru VB.

Thanks,
Dan


 
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
Automatically Hide Rows Tracy Excel Worksheet Functions 10 November 13th 08 09:18 PM
How to make a few rows visible and hide some others ... faster tskogstrom Excel Programming 2 October 5th 07 07:39 PM
faster way to hide rows w/o using autofilter? [email protected] Excel Programming 3 May 25th 06 05:39 PM
Hide rows automatically kim Excel Discussion (Misc queries) 1 September 14th 05 02:23 PM
How do I automatically hide rows RobRoy Excel Discussion (Misc queries) 8 February 2nd 05 01:12 PM


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