[Excel VBA] Progress Bar for Macro
Hello all, I have duplicated Walkenbach's progress bar:
http://spreadsheetpage.com/index.php...ess_indicator/
I'm trying to change it up a bit. The basic idea is he has a UserForm_Activate sub that runs a macro, called Main(), whenever the UserForm is shown (and that's all the UserForm_Activate does). Then, he has another macro which shows the user form, ShowDialog().
So, you run ShowDialog(), which shows the UserForm. That triggers UserForm_Activate which runs your macro, Main(), and inside Main() is code that you care about, the actual process you are trying to run, as well as code that updates the user form.
This may be the only way to do it but it seems sort of convoluted. Why can't I just have a macro that does some certain task, Walkenbach's Main(), and inside of that it shows the user form and updates it? Why do I need 3 different procedures when I just want to run one procedure that does what I need to do and shows the user form and updates the user form? Is there some easy fix here? My experience is, when I try to show the UserForm in the middle of my macro, the program stops doing anything until I close the UserForm, and then the program resumes. Obviously, this isn't the desired situation. So, maybe the answer is, "No, this is the best way."
Thanks for any help
Re: [Excel VBA] Progress Bar for Macro
Quote:
the program stops doing anything until I close the UserForm
that would be correct, in most cases vb code runs syncronously
you could call a public procedure in some other module from the useform, when it activates, but that is not really any gain, so i doubt there is a better method to do what you want, without considerably more complex coding