+ Reply to Thread
Results 1 to 8 of 8

How do i incorporate a progress bar.....

  1. #1
    Forum Contributor
    Join Date
    05-20-2008
    Posts
    162

    How do i incorporate a progress bar.....

    I'm currently using this code to extract certain data, but it can take around 15 to 20 seconds to complete. How can i incorporate a progress bar.
    Regards: JonesZoid

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    You'd have to make a userform. I implemented one for one of my macros. Here is what your code should look like:

    Please Login or Register  to view this content.
    The Counter and PctDone variables are important. How I've laid it out is just an example. You can have the macro calculate the PctDone anyway you please. Its easy to do in loops but you don't have any so you'd just have to pick parts in the code that you'd like the macro to use as reference as for when to update the progress bar.

    Now you'll want more code:
    Please Login or Register  to view this content.
    Thats used to actually expand the progress bar and display the percent complete.

    I'll try to explain in words what I did to create the Progress Bar.
    -In VBE, insert a UserForm.
    -In the bottom left corner of VBE you should see something that says "Properties-UserForm1", you'll see a number of properties, find the "Caption" property and have it say something like "Progress".
    -You'll also notice a Userform toolbar, this is what you'll use to create the UserForm. Add a "Frame" (the process is very similar to creating something like a rectangle in Excel or Word) and change the "(Name)" property to something you can recognize, like FrameProgress is what I use. The Frame is what will be used to display the progress bar, so make it stretch the entire length of the userform.
    -Add a Label control within the frame and name it something like ProgressLabel in its properties. Change the background color of the label to whatever you want, this will be the color of your progress bar that you'll see while the macro is running. It doesn't matter how long the Label is, as long as its within the Frame you're fine.
    -Add a label just above the frame and for the caption property, type a description of what the macro is doing (i.e. "Generating Numbers...") or something.
    -Finally click on the frame and for the "SpecialEffect" property, change it to "2-fmSpecialEffectSunken"

    Lastly, adjust the height and length of the userform to your liking. Now double click anywhere within the UserForm and a blank VBE area will appear allowing you to enter code. Delete anything that may show up in that area and simply type:

    Please Login or Register  to view this content.
    Now finally, this macro will be used to run/reference all the other macros:
    Please Login or Register  to view this content.
    This is the macro you'll actually want to use to run the vlookup macro, so if you have a button or menu item that you use to call the macro, instead of having it call the procedure VLookup, you'll now want it to call the procedure BeginMacro.
    Last edited by fecurtis; 06-11-2008 at 03:29 PM.

  3. #3
    Forum Contributor
    Join Date
    05-20-2008
    Posts
    162
    I've got the progress bar to come up, but it hangs. So i press the X - and the rest of my Vlookup() code runs.

    Any ideas.

    Where does UserForm11 come into play aswell....?

    JonesZoid

  4. #4
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    My mistake, thats meant to say UserForm1. Also add at the end of your Vlookup macro:

    Please Login or Register  to view this content.
    That instructs Excel to close out the UserForm.

  5. #5
    Forum Contributor
    Join Date
    05-20-2008
    Posts
    162
    Sorry to be a burden, where do the 2 UpdateProgress pieces of code go...

    JonesZoid

  6. #6
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    Man I must be having an off day today. You only need one and it has to reference UserForm1 not UserForm11, so ignore that one.

    Is it Friday yet?

  7. #7
    Forum Contributor
    Join Date
    05-20-2008
    Posts
    162
    Sorry about this, but i know my code looks good - thats due mainly to this site, and copy & pasting.
    How do i put it all together as all that happens at the mo. Is the progress bar comes up and does nothing.

    JonesZoid (Very Nooby)

  8. #8
    Forum Contributor
    Join Date
    05-20-2008
    Posts
    162
    Still having a problem. The progress bar pops up and does nothing. Close the form with the X and then my macro to compile the data kicks in. No progress bar to be seen during this.

    JonesZoid

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1