I was wondering how to activate a waiting message to pop up while one of my
longer macros is running, so that the users do not think the program froze. I
was given one VBA code, but I couldnt get it to work. Thank you.
If your macro runs long, one solution could be to simply update the
status bar every so often. For instance, let's say I have a For loop
that populates some cells, etc. In this case, I have DoEvents, just
for sake of making this seem slow:
Public Sub statusBarUpdate()
Dim i As Long
Const lastItem As Long = 1000000
For i = 1 To lastItem
' whatever you're doing
DoEvents
' update status bar every 1 percent
If (i Mod (lastItem \ 100)) = 0 Then
Application.StatusBar = "Processing " & _
Int(100 * i / lastItem) & "% complete"
End If
Next i
' reset status bar
Application.StatusBar = False
End Sub
If you have multiple loops in your macro, consider giving them
different names. Connecting, Waiting, Processing, Analyzing,
Compiling, Preparing Report - just to keep users a little engaged - or
even display something more meaningful than just the % completion
(name of item being processed, file name like installer programs do,
or whatever your scenario is). The trick is to do the update
infrequently, so as not to slow down the operation by much.