Turning off Screen Refresh

  • Thread starter Thread starter sullivan
  • Start date Start date
S

sullivan

Is there any way to turn off screen refresh while running
a program in VB?

Sullivan
 
Sullivan,

Application.screenupdating=false
.... code here ...
Application.screenupdating=true

Cheers, Pete
 
' turn it off
Application.ScreenUpdating = False

' turn it back on
Application.ScreenUpdating = True
 
Sullivan,

Use something like the following:

Application.ScreenUpdating = False
' your code here
Application.ScreenUpdating = True
 
You might want to put this in a class module as follows.

Add a a class module and name it SuspendRefresh. The code is:

Option Explicit

Private Sub Class_Initialize()
Application.ScreenUpdating = False
End Sub

Private Sub Class_Terminate()
Application.ScreenUpdating = True
End Sub

' End of class module

In your sub or function, do the following
Sub DemoScreenUpdateClass()
dim su as SuspendRefresh

' when ready to suspend the screen refresh
set su = new SuspendRefresh

' when ready to resume screen refresh
set su = Nothing

' if you don't want to resume screen refresh until the Sub or Function
ends, do nothing. VBA will
' automatically perform the "set su = Nothing" for you on Exit Sub or Exit
Function
End Sub


Mike.
 
Application.ScreenUpdating = False
Your Macro
Application.ScreenUpdating = True
 
Sullivan,

I think you are looking for the

application.screenupdating=false

command.

Best regards,
Kevin
 
Back
Top