ksrds
ksrds

Reputation: 166

Just want to show a Popup Or Status bar during running of VBA code

I have a long code & taking approx. 1 min 30 sec to execute , So I want to show a Status bar showing "Please wait...running" or a popup with the same message or anything else which on will be easy. It consist so many do while, for & if conditions.. I don't want to use any Long code Or very heavy method to show the message, Please suggest some small way to do this.

Upvotes: 0

Views: 2636

Answers (1)

user4039065
user4039065

Reputation:

Here is a short procedure that will demonstrate adjusting the Application.StatusBar property text in a loop.

Sub sb_text()
    Dim w As Long, s As Long, d As Double

    s = 2 '<~~ seconds between actions

    Application.StatusBar = "Preparing ..."
    d = Now + TimeSerial(0, 0, s): Do While Now < d: DoEvents: Loop

    For w = 1 To 5
        Application.StatusBar = "Working: " & w
        d = Now + TimeSerial(0, 0, s): Do While Now < d: DoEvents: Loop
    Next w

    Application.StatusBar = "Finished"
    d = Now + TimeSerial(0, 0, s): Do While Now < d: DoEvents: Loop

    Application.StatusBar = vbNullString
End Sub

I've set a two second pause so that you can actually observe the changes to the status bar text. In an actual procedure loop, the waiting would be replaced by actual work being done.

Upvotes: 1

Related Questions