Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running code without seeing the various steps

Status
Not open for further replies.

sedgely

Technical User
Feb 21, 2002
406
GB
Hi
i have created an Excel work book with code that does several formatting and data manipulation routines on different sheets. All works well apart from the fact that the users can see everything that happens. ie the sheets becoming active, the ranges being selected etc.
Is there a way of making it so that this is all performed "in the background" so the user just sees the result?

Cheers
Craig
 
Hi sedgely,

Code ..

Code:
Application.ScreenUpdating = False

.. before you start your stuff and ..

Code:
Application.ScreenUpdating = True

.. after you have finished.

Enjoy,
Tony
 
Thanx Tony
That worked a treat, i knew there'd be a simple solution

Craig
 
Hi
now that i've got that working i thought it might be nice if the user could see some sort of indicator that something is happening besides the hourglass cursor, can i put up a message just while the code is running, then replace with another message when the code has finished?

Cheers
Craig
 
Hi sedgely,

The simplest way is to put a message in the Status bar ..

Code:
Application.DisplayStatusBar = True
Application.StatusBar = "Please wait while I do some stuff..."

.. and, at the end ..

Code:
Application.DisplayStatusBar = False
Code:
 ' If you want
Code:
Application.StatusBar = False

But it's not very obvious to the User. For something more obvious you really need to set up a UserForm. Whichever way you choose, you can change the message as often as you like to keep the User informed of progress.

Enjoy,
Tony
 
You can also use status bar as a progress bar, works also when ScreenUpdating=False:

[tt]Application.ScreenUpdating = False
For i = 1 To MaxValue
Application.StatusBar = String(i * 30 / MaxValue, Chr(127))
' do something
Next i
Application.StatusBar = False
Application.ScreenUpdating = True[/tt]

And with API you can change colour, font and size.

combo
 
Thanks all
decided to go with the straightforward status bar option for now as it is the quickest, but when i get time i will look into the option suggested by RamziSaab as it looks quite neat.

Thanks again
Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top