Computer >> Computer tutorials >  >> Software >> Office

Keep Excel Responsive: Show Live Progress Messages While VBA Runs

Keep Excel Responsive: Show Live Progress Messages While VBA Runs

 

When the code is long and the VBA macro runs for several seconds, Excel can appear frozen or unresponsive. Even if the code is working properly, users may assume the workbook has frozen because nothing seems to be happening on screen. A simple way to avoid this problem is to display a live message in Excel’s status bar while the macro runs.

In this tutorial, we will show how to display a progress message while VBA runs. You do not need a UserForm or a graphical progress bar. In many cases, Application.StatusBar is enough.

Why Use Application.StatusBar?

Excel has a built-in status bar at the bottom of the application window. VBA can temporarily replace the normal text in that area with a custom message.

This means your macro can display updates such as:

  • Processing row 10 of 100
  • Importing data…
  • Writing formulas…
  • 65% complete

This is useful when you want users to know the macro is still running but do not want the extra work of building a full visual progress bar. You can still make the message more informative by showing row counts or percentages, but it remains a text-based solution.

Basic Syntax:

To show a message in the Excel status bar, use:

Application.StatusBar = "Processing..."

When your macro finishes, reset the status bar with:

Application.StatusBar = False

Setting Application.StatusBar = False restores control of the status bar to Excel, allowing it to display its default messages again. Never skip this step.

Basic Example: Simple Progress Message

This is the most basic version with a simple progress message. In the status bar, it will show “Running report… please wait”.

Sub SimpleStatusBar() 
 Application.StatusBar = "Running report... please wait"
 
 ' Simulate work
 Dim i As Long
 For i = 1 To 50000
 ' Your processing here
 Next i
 
 Application.StatusBar = False ' Restore the status bar
 MsgBox "Done!" 
End Sub

This works, but it only shows one fixed message. It tells the user the macro is running, but it does not show any real progress.

Show Live Progress During a Loop

In most real macros, you process rows, cells, files, or records one by one. That makes it easy to update the status bar as the loop progresses.

Sub ShowLoopProgress()
 Dim i As Long
 Dim lastRow As Long
 lastRow = Cells(Rows.Count, "A").End(xlUp).Row
 For i = 2 To lastRow 
 ' Simple action
 Cells(i, "K").Value = "Processed" 
 ' Update progress message
 Application.StatusBar = "Processing row " & (i - 1) & " of " & lastRow 
 DoEvents
 Next i
 
 Application.StatusBar = False
 MsgBox "Task completed!"
End Sub
  • DoEvents allows Excel to refresh the screen and respond while the macro is running
  • Without it, the status bar may not visibly update until the macro ends, especially in long loops
  • Do not overuse it in extremely large loops unless needed, because it can slightly slow execution

At the bottom, the status bar shows “Processing row 90 of 101”.

Keep Excel Responsive: Show Live Progress Messages While VBA Runs

Add a Percentage Message

You can customize the progress message to include a percentage. You just need to calculate the percentage and include it in the status bar text.

Sub ShowPercentageProgress()
 Dim i As Long
 Dim lastRow As Long
 Dim percentDone As Double
 lastRow = Cells(Rows.Count, "A").End(xlUp).Row
 For i = 2 To lastRow 
 ' Simple action
 Cells(i, "K").Value = "Processed" 
 ' Update progress message
 percentDone = (i - 1) / (lastRow - 1)
 Application.StatusBar = "Processing row " & (i - 1) & " of " & (lastRow - 1) & _
 " (" & Format(percentDone, "0%") & ")" 
 DoEvents
 Next i
 
 Application.StatusBar = False
 MsgBox "Task completed!"
End Sub

This code creates a clear status update for the user, showing “Processing row 14 of 100 (14%)”.

Keep Excel Responsive: Show Live Progress Messages While VBA Runs

Example with a Simple Formula Task

Let’s explore a practical example that performs a worksheet action. This version writes a simple sales amount formula in a column.

Sub ShowProgressWithFormula()
 Dim i As Long
 Dim lastRow As Long
 Dim percentDone As Double
 lastRow = Cells(Rows.Count, "H").End(xlUp).Row
 For i = 2 To lastRow 
 ' Simple action
 Cells(i, "K").Formula = "=H" & i & "*I" & i 
 ' Update progress message
 percentDone = (i - 1) / (lastRow - 1)
 Application.StatusBar = "Writing formulas... " & _
 "Row " & (i - 1) & " of " & (lastRow - 1) & _
 " (" & Format(percentDone, "0%") & ")" 
 DoEvents
 Next i
 
 Application.StatusBar = False
 MsgBox "Formulas added in column K!"
End Sub

This is a simple example, but it closely reflects the type of worksheet task many users perform.

A Text-Based “Fake Progress Bar”

Application.StatusBar cannot create a real graphical progress bar. However, you can simulate one by building a bar using characters.

Sub StatusBarWithTextProgressBar()
 Dim i As Long
 Dim lastRow As Long
 Dim percentDone As Double
 Dim barLength As Integer
 Dim filledBars As Integer
 Dim progressBar As String
 lastRow = Cells(Rows.Count, "A").End(xlUp).Row
 barLength = 20
 For i = 2 To lastRow 
 Cells(i, "K").Value = "Processed" 
 percentDone = (i - 1) / (lastRow - 1)
 filledBars = Int(percentDone * barLength)
 progressBar = String(filledBars, "|") & String(barLength - filledBars, ".")
 
 Application.StatusBar = "Progress: [" & progressBar & "] " & _
 Format(percentDone, "0%") 
 DoEvents
 Next i
 
 Application.StatusBar = False
 MsgBox "Completed!"
End Sub

Whenever you run the VBA, the status bar will display something like this:

Progress: [||||||||||……….] 67%

This is still just text, but it provides a stronger visual sense of progress.

Keep Excel Responsive: Show Live Progress Messages While VBA Runs

Best Practice: Always Reset the Status Bar

One of the most common mistakes is forgetting to restore the status bar at the end of the macro. If you do not use Application.StatusBar = False, Excel may continue showing your custom text even after the macro has finished. A safer version uses simple error handling so the status bar is reset even if something goes wrong.

Sub SafeStatusMessage()
 Dim i As Long
 Dim lastRow As Long
 Dim percentDone As Double
 On Error GoTo CleanUp
 lastRow = Cells(Rows.Count, "A").End(xlUp).Row
 For i = 2 To lastRow 
 Cells(i, "K").Value = "Processed" 
 percentDone = (i - 1) / (lastRow - 1)
 Application.StatusBar = "Processing row " & (i - 1) & " of " & (lastRow - 1) & _
 " (" & Format(percentDone, "0%") & ")" 
 DoEvents
 Next i
 
 MsgBox "Task completed!"
CleanUp:
 Application.StatusBar = False
 If Err.Number <> 0 Then
 MsgBox "Error: " & Err.Description
 End If
End Sub

This pattern is more suitable for real-world use.

Tips for Better Status Messages

A good status bar message should be short and specific. Keep your messages concise and useful. Good examples include:

  • Importing sales data…
  • Checking duplicates…
  • Formatting worksheet…
  • Processing record 45 of 200…
  • Finalizing report…

Try to match the message to the actual task being performed. This makes the macro feel more professional and easier to trust.

Ready-to-Use Reusable Pattern

You can reuse this pattern in almost any macro. Simply copy this code and insert your logic where needed.

Sub MyMacro()
 On Error GoTo CleanUp
 Dim i As Long
 Dim total As Long
 total = 100
 For i = 1 To total
 Application.StatusBar = "Processing item " & i & " of " & total
 DoEvents
 ' Your code here
 Next i
CleanUp:
 Application.StatusBar = False
End Sub

Conclusion

By following this tutorial, you can easily display a progress message while VBA runs. If you want to show users that a VBA macro is still working, Application.StatusBar is one of the simplest tools available. It is not a full progress bar, but it is often more than sufficient. This approach is easy to implement, reliable, requires minimal code, and greatly improves the user experience during long-running VBA procedures. Test it in your own macros by placing status updates inside your main loops—it only takes a few lines of code.

Get FREE Advanced Excel Exercises with Solutions!