Faking an animated image in a userform?

BBrandt

Board Regular
Joined
Jul 14, 2008
Messages
155
I've gathered that it's not possible to place an animated GIF like this:

progressbarpf7.gif


in a userform in Excel. As you might have guessed, I've created a macro that, depending on user inputs, can take a bit of time to run, and I want to display something to let the user know that Excel hasn't locked up. Ideally, this would be a sort of faux status bar like the one above that implies that there is work being done without necessarily actually indicating the amount of work completed (I figure that would be easier to code).

Do you have any recommendations about how to accomplish something like this? Ideally also I'd like to not have to download anything in order to make this work, as the spreadsheet is designed for others to use, so it would be inconvenient if they had to install an add-in or similar to get it to run. Thanks in advance!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Like this:

Code:
With UserForm1
    .FrameProgress.Caption = Format(PctDone, "0%")
    .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
End With

You will need to assign a value to PctDone.
 
Upvote 0
Do I keep my code at the end of the Userform code? Or do I place it somwhere in the middle of the Userform code?
 
Upvote 0
The progress UserForm has to call your procedure and your procedure has to update the progress bar at appropriate times.
 
Upvote 0
Alternatly, you could make your own porogress bar.

Code:
Label1.BackColor = RGB(0, 0, 0)
Label1.Height = 20

For i = 1 to Limit
    Rem do something slow
    Label1.Width = 400 * Limit / i
Next i
 
Upvote 0
Hi Mikerickson/ Andrew,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
I'm not giving up (ha-ha).<o:p></o:p>
I was able to slow down userfom1 image to coincide with the time it takes for my macro to run, but I have no idea where to place the “Calls" for my others codes in the "main" code below:<o:p></o:p>

Any suggestions?

Thank you,
FP

PHP:
 Sub Test()
'   The UserForm1_Activate sub calls Main
    UserForm1.LabelProgress.Width = 0
    UserForm1.Show
End Sub
Sub Main()
'   Inserts random numbers on the active worksheet
    Dim Counter As Integer
    Dim RowMax As Integer, ColMax As Integer
    Dim r As Integer, c As Integer
    Dim PctDone As Single
    
    Sheets("Random").Visible = True
    Sheets("Random").Select
    If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
    Cells.Clear
    Application.ScreenUpdating = False
    Counter = 1
    RowMax = 1000
    ColMax = 30
    For ro = 1 To RowMax
    For co = 1 To ColMax
            Cells(ro, co) = Int(Rnd * 1000)
            Counter = Counter + 1
        Next co
        PctDone = Counter / (RowMax * ColMax)
With UserForm1
For iii = 1 To 20000
    Rem do something slow
    .FrameProgress.Caption = Format(PctDone, "0%")
    .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
Next iii
End With
 
Call WAIVES: Call BPK_Collections: Call Loc_Dept_User: Call POS_Collections: Call HB_Sum: Call HB_Col: _
Call Voids: Call Cash_Drawer: Call OverShort: Call Brinks: Call Open_Drawer: Call Small_POS_Collections
        
        DoEvents
  Next ro
    Unload UserForm1
   
End Sub
 
Upvote 0
Why don't you update the progress between each call here?

Code:
Call WAIVES: Call BPK_Collections: Call Loc_Dept_User: Call POS_Collections: Call HB_Sum: Call HB_Col: _
Call Voids: Call Cash_Drawer: Call OverShort: Call Brinks: Call Open_Drawer: Call Small_POS_Collections
 
Upvote 0
How? Like this?

PHP:
Call WAIVES
For iii = 1 To 20000
    .FrameProgress.Caption = Format(PctDone, "0%")
    .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
Next iii
 
Call BPK_Collections
For iv = 1 To 20000
    .FrameProgress.Caption = Format(PctDone, "0%")
    .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
Next iv
ETC......
 
Upvote 0
More like:

Code:
    PctDone = 0
    With UserForm1
        Call WAIVES
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call BPK_Collections
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call Loc_Dept_User
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call POS_Collections
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call HB_Sum
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call HB_Col
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call Voids
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call Cash_Drawer
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call OverShort
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call Brinks
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call Open_Drawer
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        Call Small_POS_Collections
        PctDone = PctDone + 1 / 12
        .FrameProgress.Caption = Format(PctDone, "0%")
        .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
    End With
 
Upvote 0

Forum statistics

Threads
1,215,573
Messages
6,125,608
Members
449,238
Latest member
wcbyers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top