Forum

Progress Bar while ...
 
Notifications
Clear all

Progress Bar while running several macros in a row

6 Posts
2 Users
0 Reactions
168 Views
(@mavet)
Posts: 3
Active Member
Topic starter
 

Hi Phil,
I have a macro that involves running several other macros in a row, to get the final result.
It's called New_Comp (module 10) in ScreenRunner.xlsm
It takes about 45 seconds on MS Office Home and Student 2016 with Windows 10.

Is there a way to display a Progress Bar while the several macros are running?

Cheers,
Aussie Mark

 
Posted : 27/05/2020 8:08 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Mark,

Can you supply the workbook plz?

Phil

 
Posted : 27/05/2020 8:55 pm
(@mavet)
Posts: 3
Active Member
Topic starter
 

Hi Phil,

I have attached the ScreenRunner.xlsm file to this message but its over the limit (I think that happened yesterday too).

I'll send you a Dropbox link to ScreenRunner.xlsm, so you can then have a go at running it.
I've attached a summary of the macos in the meantime so you can see how it runs.

The main macro I'd like the Progress BAr on is the New_Comp macro

Cheers,

Mark

 
Posted : 29/05/2020 2:08 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Mark,

Please see attached.  This code is taken from here

VBA Progress Bar

I've rewritten the code to be more adaptable, so that when initialized, you can specify the number of steps it takes to get to 100%.

As you are calling 13 subs, you can specify Steps = 13 before calling InitProgressBar (Steps). 

If you change the number of subs you're calling just change the value of Steps to match.

I've put the code in Module10 and added the necessary calls in your New_comp sub. 

I've also included a TestProgressBar() sub so you can play about with it.

Regards

Phil

 
Posted : 29/05/2020 6:53 am
(@mavet)
Posts: 3
Active Member
Topic starter
 

Hi Phil,

Many thanks for setting up the Progress Bar for me.

I noticed it appeared better in your TestProgressBar module when I run the loop at... For counter = 1 To 10000
As you highlighted, it slows the Progress Bar down enough so viewers can see it progressing.

How would I place that loop in the New_Comp module (which runs the 13 macros one after another)?

I tried placing a "pause" break after every 3 macros, and could see the Bar better, but I don't think this is the best practice.

Cheers,

Mark

 
Posted : 04/06/2020 5:22 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

no worries Mark.

You can copy/paste the loop into the ShowProgress sub to create an artificial delay - see attached.

Though I'd be happy if my code was quick enough not to need a progress bar 🙂

Regards

Phil

 
Posted : 04/06/2020 10:42 pm
Share: