Progress bar add to an existing userform

quikdraw

New Member
Joined
Mar 1, 2025
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I have a user form I use for several different
functions around my workplace. It's a custom interface I mod based on what the users needs are.

For the application I am working on now, which creates reports that are currently put together manually. The userform has check boxes for what reports they would like generated from an imported master data table and has comboboxes to select the month they want the reports generated for.

I would like to add a progress bar to my existing userform. All of the examples I found searching the web wrap a userform around a caption more or less. Since I already have a user form, I don't know how to embed one inside another. Is there a method to point the progress bar code to the caption itself on my existing user form instead?
 
To adapt a progressbar you need to know what you are doing:
- are you reading many records or
- are they only processes or
- even each process has to read many records.

I present you an option, if you have a single process and it reads many records.

1. Add a Frame1 in your userform.
2. Inside the Frame add a Label and name it LabelProgress.
3. When you are going to run your process, launch the procedure called RunProgressBar
4. Within the procedure you must enter your code.

To start your process:
VBA Code:
  Call RunProgressBar

Replace 'here your code' lines for your code.
Change this line: lrPro = Range("A" & Rows.Count).End(xlUp).Row
By the line where you are getting the last row with data. But using the same lrPro variable

VBA Code:
Sub RunProgressBar()
  Dim iPro&, jPro&, nPro&, xPro&, lrPro&
  
  With Frame1
    .Caption = ""
    .Width = 500
    .Height = 32
  End With
  
  With LabelProgress
    .Width = 0
    .Left = 0
    .Top = 4
  End With
  
  nPro = 1
  xPro = 10
  '
  lrPro = Range("A" & Rows.Count).End(xlUp).Row
  For iPro = 1 To lrPro
  
    'here your code
    'here your code
    'here your code
    'here your code
    'here your code

    If (nPro * 100) / lrPro >= xPro Then
      Frame1.Caption = xPro & " %"
      LabelProgress.Width = LabelProgress.Width + 50
      xPro = xPro + 10
    End If
    nPro = nPro + 1
    DoEvents
  Next
End Sub

Example:
1740870181395.png

1740870219771.png

1740870260712.png

If you have problems adapting the progressbar, then put all your code here and I'll help you.

😇
 
Upvote 0
Maybe you need the progressbar to show the progress because your process is very slow, it would be best to optimize your process.

Likewise, put all your code here and explain what it does.
 
Upvote 0

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