B
brzak
this is probably really simple and i'm not thinking...
I am currently using a modified version of a progress bar kinbdly made
available on the J-Walk website [link: http://j-walk.com/ss/Excel/tips/tip34.htm]
The steps involved are as follows.
1. Assign a button to run a macro which shows a UserForm, e.g.
Sub MacroWithProgressBar()
UserForm1.Show
End Sub
2. Create a routine which runs on activation of the UserForm, and
calls the required macro e.g.
Private Sub UserForm1_activate()
Call MyMacro
End Sub
3. Then a couple of lines are added into any loops to display the
progress (works by altering the length of a label which has
baskground colour).
If you're still following, now for my question:
I have several macros in my workbook for which I would like to display
a progress bar. With the current setup, I would need to create a
different UserForm for each macro because it always calls the same Sub
on activation.
Is it possible to pass a variable to Activate?
In the process of writing this I have thought of a possible
solution
I could define a new global variable, e.g:
Public ThisMacroWantsAProgressBar as String
then I would only need to create one initial sub for each macro, e.g.
Sub MacroWithProgressBar1()
ThisMacroWantsAProgressBar = MyMacro1
UserForm1.Show
End Sub
Sub MacroWithProgressBar2()
ThisMacroWantsAProgressBar = MyMacro2
UserForm1.Show
End Sub
etc. and so now the activate sub looks like:
Private Sub UserForm1_activate()
Call ThisMacroWantsAProgressBar
End Sub
THanks
I am currently using a modified version of a progress bar kinbdly made
available on the J-Walk website [link: http://j-walk.com/ss/Excel/tips/tip34.htm]
The steps involved are as follows.
1. Assign a button to run a macro which shows a UserForm, e.g.
Sub MacroWithProgressBar()
UserForm1.Show
End Sub
2. Create a routine which runs on activation of the UserForm, and
calls the required macro e.g.
Private Sub UserForm1_activate()
Call MyMacro
End Sub
3. Then a couple of lines are added into any loops to display the
progress (works by altering the length of a label which has
baskground colour).
If you're still following, now for my question:
I have several macros in my workbook for which I would like to display
a progress bar. With the current setup, I would need to create a
different UserForm for each macro because it always calls the same Sub
on activation.
Is it possible to pass a variable to Activate?
In the process of writing this I have thought of a possible
solution
I could define a new global variable, e.g:
Public ThisMacroWantsAProgressBar as String
then I would only need to create one initial sub for each macro, e.g.
Sub MacroWithProgressBar1()
ThisMacroWantsAProgressBar = MyMacro1
UserForm1.Show
End Sub
Sub MacroWithProgressBar2()
ThisMacroWantsAProgressBar = MyMacro2
UserForm1.Show
End Sub
etc. and so now the activate sub looks like:
Private Sub UserForm1_activate()
Call ThisMacroWantsAProgressBar
End Sub
THanks