Forum Discussion
AndyPe
Jul 30, 2025Copper Contributor
Progressbar in Excel (VBA)
Maybe I'm trying to do the impossible. Who knows ? I've made a vba uerform to do several things (too long to explain) but what I would like to do is while the progressbar is running to have a small ...
- Jul 31, 2025
Private Sub UserForm_Initialize() ' Initial Setup for the Progress Bar and Text Me.ProgressBar.Width = 0 ' Initially empty Me.ProgressText.Caption = "" ' Initially empty text End Sub Sub StartProgress() Dim i As Integer Dim progress As Integer Dim fullText As String fullText = "Processing..." ' Start Progress Loop For i = 1 To 100 ' Update Progress Bar width progress = i * 2 ' Adjust multiplier to fit your form size Me.ProgressBar.Width = progress ' Reveal text letter by letter If i <= Len(fullText) Then Me.ProgressText.Caption = Mid(fullText, 1, i) End If ' Bring the text to the front each time it updates (ensures text stays visible) Me.ProgressText.ZOrder msoSendToFront ' Small Delay for Animation Effect DoEvents Application.Wait Now + TimeValue("00:00:00.05") ' Adjust speed of progress Next i End SubIn theory, this should solve your problem of displaying the text letter by letter while animating the progress bar. The key is to ensure the text control is always on top using .ZOrder, and that both the progress bar and the text are dynamically updated within the loop. Otherwise, insert a file into the theme.
Hope this helps.
NikolinoDE
Jul 31, 2025Platinum Contributor
Private Sub UserForm_Initialize()
' Initial Setup for the Progress Bar and Text
Me.ProgressBar.Width = 0 ' Initially empty
Me.ProgressText.Caption = "" ' Initially empty text
End Sub
Sub StartProgress()
Dim i As Integer
Dim progress As Integer
Dim fullText As String
fullText = "Processing..."
' Start Progress Loop
For i = 1 To 100
' Update Progress Bar width
progress = i * 2 ' Adjust multiplier to fit your form size
Me.ProgressBar.Width = progress
' Reveal text letter by letter
If i <= Len(fullText) Then
Me.ProgressText.Caption = Mid(fullText, 1, i)
End If
' Bring the text to the front each time it updates (ensures text stays visible)
Me.ProgressText.ZOrder msoSendToFront
' Small Delay for Animation Effect
DoEvents
Application.Wait Now + TimeValue("00:00:00.05") ' Adjust speed of progress
Next i
End SubIn theory, this should solve your problem of displaying the text letter by letter while animating the progress bar. The key is to ensure the text control is always on top using .ZOrder, and that both the progress bar and the text are dynamically updated within the loop. Otherwise, insert a file into the theme.
Hope this helps.