Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tg tg is offline
external usenet poster
 
Posts: 58
Default Screen Flickers and slows down worksheet functions

Hello,

I have a code:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
End Sub

That luckily I was able to find in this Forum. The problem is that this code
makes my worksheets run really slow. Every time the macro updates the whole
workbook slows down, I cannot type of make any changes till the macro is done
updating. This sometimes takes up to 5 seconds and makes the screen flickers.
Is there any way to stop the flickering and speed up the process without
compromisisng the code?

Thank you very much,
TG
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Screen Flickers and slows down worksheet functions

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
Application.ScreenUpdating = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

--
Gary''s Student - gsnu200826


"TG" wrote:

Hello,

I have a code:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
End Sub

That luckily I was able to find in this Forum. The problem is that this code
makes my worksheets run really slow. Every time the macro updates the whole
workbook slows down, I cannot type of make any changes till the macro is done
updating. This sometimes takes up to 5 seconds and makes the screen flickers.
Is there any way to stop the flickering and speed up the process without
compromisisng the code?

Thank you very much,
TG

  #3   Report Post  
Posted to microsoft.public.excel.programming
tg tg is offline
external usenet poster
 
Posts: 58
Default Screen Flickers and slows down worksheet functions

Hey Gary, thanks for yourhelp but it still seems slow (about the same).
any other suggestions?

"Gary''s Student" wrote:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
Application.ScreenUpdating = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

--
Gary''s Student - gsnu200826


"TG" wrote:

Hello,

I have a code:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
End Sub

That luckily I was able to find in this Forum. The problem is that this code
makes my worksheets run really slow. Every time the macro updates the whole
workbook slows down, I cannot type of make any changes till the macro is done
updating. This sometimes takes up to 5 seconds and makes the screen flickers.
Is there any way to stop the flickering and speed up the process without
compromisisng the code?

Thank you very much,
TG

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Screen Flickers and slows down worksheet functions

Just be sure you are not using the =SUBTOTAL() function anywhere in your
worksheet. You can get into a REALLY bad loop if the macro hides/unhides
rows and this causes SUBTOTAL to re-calculate and this causes the macro to
re-enter, etc.....
--
Gary''s Student - gsnu200826


"TG" wrote:

Hey Gary, thanks for yourhelp but it still seems slow (about the same).
any other suggestions?

"Gary''s Student" wrote:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
Application.ScreenUpdating = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

--
Gary''s Student - gsnu200826


"TG" wrote:

Hello,

I have a code:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
End Sub

That luckily I was able to find in this Forum. The problem is that this code
makes my worksheets run really slow. Every time the macro updates the whole
workbook slows down, I cannot type of make any changes till the macro is done
updating. This sometimes takes up to 5 seconds and makes the screen flickers.
Is there any way to stop the flickering and speed up the process without
compromisisng the code?

Thank you very much,
TG

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Screen Flickers and slows down worksheet functions

The little bit of work the code does is not the cause of the slowdown.

You're only hiding/unhiding 4 rows.

What else do you have in your workbook?

The entire workbook is calculating so you could have calculations on other
sheets that take the time.

Or other calculations on the sheet with the code.

Have you tried the code in a workbook with just one sheet?

It is possible to disable calculation on other sheets when you activate the
sheet in question. But you have re-enable, you can't force a re-calc of
those other sheets.

If "c8,b55,b56,b57" are referencing other sheets' cells then disabling
calculation would be a non-starter.


Gord Dibben MS Excel MVP

On Tue, 13 Jan 2009 09:16:07 -0800, TG wrote:

Hey Gary, thanks for yourhelp but it still seems slow (about the same).
any other suggestions?

"Gary''s Student" wrote:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
Application.ScreenUpdating = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

--
Gary''s Student - gsnu200826


"TG" wrote:

Hello,

I have a code:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
End Sub

That luckily I was able to find in this Forum. The problem is that this code
makes my worksheets run really slow. Every time the macro updates the whole
workbook slows down, I cannot type of make any changes till the macro is done
updating. This sometimes takes up to 5 seconds and makes the screen flickers.
Is there any way to stop the flickering and speed up the process without
compromisisng the code?

Thank you very much,
TG




  #6   Report Post  
Posted to microsoft.public.excel.programming
tg tg is offline
external usenet poster
 
Posts: 58
Default Screen Flickers and slows down worksheet functions

I have made sure that am not using the=subtotal(). I have noticed that once I
close and reopen the spreadsheet it starts to run much faster, but as I
continue to use it it starts to slow down quite a bit. What can i do to clear
the "buffer" of memory in my code, so everytime it runs the macro it sees it
as a fresh run. The code utilize is on the original message.
Thanks.
TG

"Gary''s Student" wrote:

Just be sure you are not using the =SUBTOTAL() function anywhere in your
worksheet. You can get into a REALLY bad loop if the macro hides/unhides
rows and this causes SUBTOTAL to re-calculate and this causes the macro to
re-enter, etc.....
--
Gary''s Student - gsnu200826


"TG" wrote:

Hey Gary, thanks for yourhelp but it still seems slow (about the same).
any other suggestions?

"Gary''s Student" wrote:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
Application.ScreenUpdating = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

--
Gary''s Student - gsnu200826


"TG" wrote:

Hello,

I have a code:

Private Sub Worksheet_Calculate()
Const MyCells As String = "c8,b55,b56,b57" 'adjust the range to suit
On Error GoTo stoppit
Application.EnableEvents = False
For Each cell In Me.Range(MyCells)
With cell
If .Value = "" Then
.EntireRow.Hidden = True
Else
.EntireRow.Hidden = False
End If
End With
Next
stoppit:
Application.EnableEvents = True
End Sub

That luckily I was able to find in this Forum. The problem is that this code
makes my worksheets run really slow. Every time the macro updates the whole
workbook slows down, I cannot type of make any changes till the macro is done
updating. This sometimes takes up to 5 seconds and makes the screen flickers.
Is there any way to stop the flickering and speed up the process without
compromisisng the code?

Thank you very much,
TG

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
Screen flickers and text disappears/moves?? G Excel Discussion (Misc queries) 10 March 31st 10 02:28 PM
Display Problem in Excel 2007: Screen flickers an rows blanked out OZL103 Excel Discussion (Misc queries) 2 June 23rd 08 05:23 PM
Screen "Flickers" When macro Starts !! monir Excel Programming 6 December 18th 07 07:29 PM
Spreadsheet screen flickers for a few second when using a condition wayne Excel Programming 5 January 25th 05 03:41 PM
VBA code slows to a snails crawl when screen saver activated Stephen Bain Excel Programming 2 October 30th 03 06:06 PM


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