Jump to content

Progress Bar

- - - - -

  • Please log in to reply
6 replies to this topic

#1
WolfEyes

WolfEyes

    Newbie

  • Members
  • Pip
  • 5 posts
I'am new to Excel and trying out a spreadsheet that simply collates daily input data for work.

I am trying different aspects of VBA at the moment, just to see what effects they have on my workbook.

I have made a Progress Bar with a user form and want it to show when the workbook is opened, mostly just for effects, like bluff really. It doesnt have to do anything just look as though its loading data for 3/4 seconds but I have no idea what coded to use or how to have the progress bar show when the workbook is opened and close when it reaches 100%.

Is anyone able to help me ?

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 855 posts
  • Location:Arkansas
May I ask, if it's for work, why do you want to code a delay? Wouldn't you want it to open as quickly as possible for time efficiency?

#3
WolfEyes

WolfEyes

    Newbie

  • Members
  • Pip
  • 5 posts
No real reason, yes its for work but I'am my own boss so time is irrelevant, as I posted I just wanted it for like special effects. Thats all.

#4
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 855 posts
  • Location:Arkansas
Well, as an exercise then, I would use a for loop, and run it from zero to the progress bar's maximum value. In the body of the for loop, set the progress bar's value to the value of your loop iterator. You can also add something like a sleep statement in the for loop body and make it wait a couple of milliseconds on each iteration to increase the time that it will take to fill the progress bar. You'll have to play around with the times to see what effect you'll get.

#5
WolfEyes

WolfEyes

    Newbie

  • Members
  • Pip
  • 5 posts
Thats the trouble, I dont know how to do the code :( I made the userform from a book but it was for filling cells with random numbers, not to just like bluff its doing something :(

#6
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 855 posts
  • Location:Arkansas
What do you have so far? Do you have the form built in the visual editor?

Here's how you do a for loop in VB, assuming the min/max values of the progress bar are their defaults of 0 and 100:


For i = 0 To 100

[INDENT]UserForm1.ProgressBar1.Value = i[/INDENT]

Next i


You can put UserForm1.Hide at the end to automatically close the form if you want.

#7
WolfEyes

WolfEyes

    Newbie

  • Members
  • Pip
  • 5 posts
Ok I'll try that :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users