Results 1 to 2 of 2

Thread: [Excel VBA] Progress Bar for Macro

  1. #1

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    [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
    Last edited by ActSciMan; Jul 11th, 2011 at 03:28 PM. Reason: clarify

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [Excel VBA] Progress Bar for Macro

    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
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width