How should I Notify the user during a long process?

calendar_today Asked Dec 7, 2011
thumb_up 8 upvotes
history Updated April 16, 2026

Question posted 2011 · +3 upvotes

I have some long processes that require notifications to the user at successive stages, so that he doesn’t get to believe Excel has crashed down.

How could I display asynchronous messages to the user in Excel, using VBA ?

Accepted answer +8 upvotes

You can use the status bar in Excel to do this:

Application.StatusBar = "status message"

Here is an example on how to implement this: http://www.vbaexpress.com/kb/getarticle.php?kb_id=87

Below is the code from the site (added line break to make is easier to read):

Sub StatusBar()

Dim x As Integer
Dim MyTimer As Double

'Change this loop as needed.
For x = 1 To 250
    'Dummy Loop here just to waste time.
    'Replace this loop with your actual code.
    MyTimer = Timer
    Do
        Loop While Timer - MyTimer < 0.03
        Application.StatusBar = _
        "Progress: " & x & " of 250: " & Format(x / 250, "Percent")
    DoEvents
Next x

Application.StatusBar = False

End Sub

UPDATE: I do want to add that updating the status bar will result in a sizable hit in performance (quite a bit actually), so you should only update it in approriate intervals. Here’s an example of what I mean (I use MOD here to ensure we only increment each 1000):

Sub test()

Dim i As Long
Dim temp As String

For i = 1 To 1000000
    temp = "testing 123, testing 123"
    If i Mod 1000 = 0 Then
        Application.StatusBar = "Processing " & i & "/1,000,000..."
    End If
Next

Application.StatusBar = "Ready"

End Sub

Also note that you want to reset the text to “Ready” otherwise it’ll be left as if it were in the loop.

3 code variants in this answer

  • Variant 1 — 1 lines, starts with Application.StatusBar = "status message"
  • Variant 2 — 20 lines, starts with Sub StatusBar()
  • Variant 3 — 15 lines, starts with Sub test()

Top excel-vba Q&A (6)

+8 upvotes ranks this answer #88 out of 136 excel-vba solutions on this site .