Answers for "ProgressBar Ecel StatusBar"

0

ProgressBar Ecel StatusBar

Sub StatusBar_Updater()
Dim CurrentStatus As Integer
Dim NumberOfBars As Integer
Dim pctDone As Integer
Dim lastrow As Long, i As Long
lastrow = Range("a" & Rows.Count).End(xlUp).Row

'(Step 1) Display your Status Bar
NumberOfBars = 40
Application.StatusBar = "[" & Space(NumberOfBars) & "]"

For i = 1 To lastrow
'(Step 2) Periodically update your Status Bar
    CurrentStatus = Int((i / lastrow) * NumberOfBars)
    pctDone = Round(CurrentStatus / NumberOfBars * 100, 0)
    Application.StatusBar = "[" & String(CurrentStatus, "|") & _
                            Space(NumberOfBars - CurrentStatus) & "]" & _
                            " " & pctDone & "% Complete"
    DoEvents
    '--------------------------------------
    'the rest of your macro goes below here
    '
    '
    '--------------------------------------
'(Step 3) Clear the Status Bar when you're done
    If i = lastrow Then Application.StatusBar = ""
Next i
End Sub
Posted by: Guest on October-20-2021

Browse Popular Code Answers by Language