Yes. Excel VBA can show progress without a UserForm by updating Excel’s status bar, writing progress to a worksheet cell, or resizing a shape on a worksheet. The status bar is the quickest option; a cell or shape is better when the progress needs to stay visible alongside the workbook.
Why show progress without a UserForm?
A UserForm is a custom VBA window that can contain labels, buttons, and a progress indicator. It is useful for polished interfaces, but it takes extra setup and code. For a macro that only needs to reassure someone that a long task is moving forward, a UserForm can be more machinery than necessary.
Excel already offers two useful places to show progress: the status bar at the bottom of the application and cells on a worksheet. A worksheet shape can also act as a visual bar. These options avoid building a separate window, although they do not provide all the features of a form. For example, a status-bar message cannot include a clickable Cancel button.
A progress indicator is only an estimate based on the work the macro has completed. It does not make a macro run faster, and it cannot predict the remaining time accurately if some rows or operations take much longer than others.
Method 1: Use Excel’s status bar
The status bar is usually the best starting point. Assign text to Application.StatusBar to replace Excel’s normal status message with a progress message. Include the completed unit count and, if useful, a percentage. When the macro finishes, assign False to Application.StatusBar so Excel restores its normal status bar.
This example reads values from A2:A1001 on the active worksheet, trims leading and trailing spaces from text, and writes the results to column B. Error values in the source are copied unchanged. It updates the status every 25 rows rather than after every single row, which avoids spending too much time refreshing the message.
Save a copy of the workbook before running any macro. VBA changes cannot be undone with Ctrl+Z. The example expects an active worksheet and writes into B2:B1001, so check that those cells are suitable before running it.
Sub CopyTrimmedValuesWithProgress()
' Copy A2:A1001 to column B and report progress in Excel's status bar.
Dim ws As Worksheet
Dim sourceRange As Range
Dim i As Long
Dim total As Long
Dim errorText As String
On Error GoTo HandleError
Set ws = ActiveSheet
Set sourceRange = ws.Range("A2:A1001")
total = sourceRange.Rows.Count
For i = 1 To total
If IsError(sourceRange.Cells(i, 1).Value) Then
ws.Cells(sourceRange.Row + i - 1, "B").Value = sourceRange.Cells(i, 1).Value
Else
ws.Cells(sourceRange.Row + i - 1, "B").Value = _
Trim$(CStr(sourceRange.Cells(i, 1).Value))
End If
If i Mod 25 = 0 Or i = total Then
Application.StatusBar = "Processing " & i & " of " & total & _
" (" & Format(i / total, "0%") & ")"
DoEvents
End If
Next i
GoTo CleanExit
HandleError:
errorText = Err.Description
CleanExit:
Application.StatusBar = False
If Len(errorText) > 0 Then MsgBox "The macro stopped: " & errorText
End Sub
The percentage is calculated as completed rows divided by the total number of rows. At row 500, for example, the displayed progress is 50%. DoEvents lets Excel process pending interface events, so the status bar can refresh while the macro runs. It is placed only at update intervals because calling it on every iteration can add unnecessary overhead.
Method 2: Show progress in a worksheet cell
A cell is a good choice when you want the progress display to remain in the workbook, or when Excel’s status bar is hidden or hard to notice. Pick a clear location, such as D1, and have the macro write a fraction from 0 to 1 as it completes work. Format the cell as a percentage, or apply a data bar using Home > Conditional Formatting > Data Bars.
For the sample macro above, add a progress-cell update inside the same reporting condition, after the status-bar assignment:
ws.Range("D1").Value = i / total
Format D1 as a percentage before running the macro. With the example’s 1,000 source rows, a value of 0.5 displays as 50%. If you apply a conditional-formatting data bar, the cell shows both the number and a filled bar. Set up the formatting once rather than recreating it during every update. Choose a cell that will not overwrite data, and consider adding a label such as “Progress” in C1.
A cell indicator is easy to inspect after the macro ends, but a final value of 100% may remain on the sheet until the next run. That can be useful as a record of completion; alternatively, the macro can clear the cell during cleanup if the display should disappear. If the macro can fail, make its final message or cell text distinguish “complete” from “stopped” so an old or partial percentage is not mistaken for success.
Method 3: Fill a shape on the worksheet
For a more visual display, place two rectangle shapes on a worksheet: a track behind and a colored fill shape in front. Give the fill shape a starting width of zero, then increase its width in proportion to completed work. Conceptually, the fill width is the track width multiplied by the completion fraction. A value of 0.5 fills half the track; a value of 1 fills it completely.
This approach still avoids a UserForm, but it needs more setup than a status message or cell. Name the shapes clearly in the Selection Pane, keep them together in a reserved area, and ensure the track is wider than the fill. The macro must refer to the correct worksheet and shape names. If the worksheet is protected, or the shapes are renamed or deleted, updating the bar may fail. A cell with a conditional-formatting data bar is often simpler when a graphic is not essential.
Shapes can be worthwhile for a dashboard or a workbook used by people who may overlook the status bar. They are less useful for a task that runs invisibly or quickly. Avoid refreshing shape size on every loop iteration: update it at sensible intervals, just as you would update a cell or status message.
How to choose the right display
Choose based on where the user needs to see progress and how much setup the workbook can justify:
- Status bar: Best for a quick, unobtrusive message with a count or percentage. It requires little worksheet preparation.
- Worksheet cell: Best when progress should be visible in the workbook or remain available for review. Conditional formatting can make the value look like a bar.
- Worksheet shape: Best when a prominent graphic matters. It needs more layout and maintenance than the other two choices.
For most one-off macros, start with the status bar. For a workbook-based interface, start with a cell and a data bar. Use shapes when there is a specific visual reason to do so. If users need to cancel safely, see multiple stages, or interact with the running task, a UserForm may actually be the more appropriate tool despite the additional work.
Make the percentage meaningful
A percentage is only as reliable as the total used to calculate it. A loop over a known range has a natural total: the number of rows. If the macro processes a variable number of records, determine that number before reporting progress where possible. For a task with several phases, a row count in the current phase can be misleading: the bar might reach 100%, then start over while a later phase runs.
For a multi-stage macro, either display the current phase and its local count, such as “Stage 2 of 3: 40 of 200,” or estimate a weighted overall percentage. Weighting phases is useful only if the estimated shares reflect their real workload. When the duration is unpredictable, an honest message such as “Reading files…” or “Processing records…” is more informative than a precise-looking but inaccurate time estimate.
Do not update the display too frequently. A long loop may contain thousands of small operations, and refreshing the interface on every one can slow the work. Updating every few dozen or few hundred iterations is a reasonable starting point; adjust the interval to the task. If each iteration takes a long time, update more often. If the task is fast, a progress bar may flash too briefly to help.
Common problems and safe cleanup
If the status bar stays stuck on a progress message after the macro stops, the code likely did not reach its reset line. Use a cleanup path that runs both after normal completion and after a handled error. In the sample, the CleanExit section resets the status bar in either case. More complex macros should also restore any application settings they changed, such as calculation mode or screen updating.
If the status bar does not visibly change, check that Excel is not currently displaying another message and that the macro reaches the update condition. The status bar belongs to the Excel application, not an individual workbook, so another macro or add-in may also change it. A worksheet cell can be a more dependable display when multiple processes might use the status bar.
DoEvents can make Excel responsive, but it also allows pending events to run. In a macro with event handlers or controls that can start the same procedure again, that can create re-entry problems. Keep the update interval reasonable, and prevent a second run from starting if concurrent execution would be unsafe. The sample does not provide a cancel button; a progress display should not imply that cancellation is available when it is not.
Macros can modify or overwrite workbook data, and Ctrl+Z will not reverse those changes. Save a separate copy before running unfamiliar code, verify the input and output ranges, and enable macros only in files you trust. Save a workbook containing VBA in a macro-enabled format such as .xlsm; saving as a standard .xlsx file does not preserve VBA code.
Windows, Mac, and Excel for the web
This guidance is for Excel for Microsoft 365 on Windows. In desktop Excel for Windows, Alt+F11 opens the Visual Basic Editor; the Developer tab’s Visual Basic command is another route. On a Mac, the Visual Basic Editor is available in desktop Excel, and Option+F11 is the usual shortcut (some keyboards require Fn as well). Ribbon and keyboard details can vary with the Mac keyboard and Excel settings.
Excel for the web does not run VBA macros. A workbook can be opened there, but use desktop Excel to run this VBA code. The status bar, worksheet cells, and shapes are workbook or application interface elements; their exact appearance can differ between Windows and Mac. If the workbook must run in a browser, VBA progress code is not the right approach.
Frequently Asked Questions
Can Excel VBA show a progress bar without a UserForm?
Yes. Update Application.StatusBar, write a completion fraction to a worksheet cell, or resize a worksheet shape. A cell with a conditional-formatting data bar gives a visual bar without creating a form.
How do I reset the status bar after a macro?
Set Application.StatusBar = False when the macro finishes. Put the reset in a cleanup section that also runs after errors, so a stopped macro does not leave custom text in Excel’s status bar.
Does DoEvents make a VBA macro faster?
No. DoEvents yields briefly so Excel can process pending events and refresh its interface. It can improve responsiveness, but calling it too often adds overhead and can allow other event code to run.
Can users cancel a status-bar progress display?
Not by clicking the status-bar message. It is text, not a cancel control. A cancelable task needs separate cancellation logic, such as a control or a carefully checked flag; a UserForm is one way to provide a dedicated button.
Will this VBA progress bar work in Excel for the web?
No. Excel for the web does not execute VBA. Run the macro in desktop Excel for Windows or Mac, or choose a different automation approach if the task must run in a browser.
Related
- Excel Text to Columns Shortcut: Windows and Mac
- Excel Text to Columns: Split Cells at Line Breaks Easily
- Excel Text to Columns by Word: Methods That Work
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA UserForm Activate vs InitializeIn Excel VBA, use UserForm_Initialize to set up a form when it is loaded, and use UserForm_Activate for…
- VBA Excel Active Workbook Path: Get It CorrectlyIn Excel VBA, use ActiveWorkbook.Path to get the folder path of the workbook that is active; it does…
- Excel VBA Copy and Paste a Column: Examples and TipsTo copy a column with Excel VBA, use sourceWs.Columns("B").Copy Destination:=targetWs.Columns("D"), replacing the worksheet variables and column letters with…
- Excel VBA Active Worksheet Reference ExplainedIn Excel VBA, use ActiveSheet to refer to the sheet currently active in the active workbook. For a…
- Excel VBA: What It Does, How It Works, and When to Use ItExcel VBA is the programming language built into the desktop versions of Microsoft Excel for automating tasks and…
- Excel VBA Enum: How It Works and When to Use ItAn Excel VBA Enum is a named set of numeric constants: it lets code use readable labels such…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.