Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Progress Bar

Hello everyone,

I am kind of new to VBA and wanted to create a progress
bar when my macro was running. I was able to to find out
how to create the bar itself under userform and call it
from code that I got from the internet (below), but I
can't figure out how to set my own parameters, the sample
below does not fit what I need, I have my own macro to run
and can't figure out how to implement it to the main sub
routine. I am at home now and cannot suppply my macro, but
I was wondering if anyone knows a website that I can GOTO
to have a better understanding

Sub ShowUserForm()
UserForm1.Show
End Sub

Sub Main()
Dim Counter As Integer
Dim RowMax As Integer, ColMax As Integer
Dim r As Integer, c As Integer
Dim PctDone As Single

Application.ScreenUpdating = False
' Initialize variables.
Counter = 1
RowMax = 100
ColMax = 25

' Loop through cells.
For r = 1 To RowMax
For c = 1 To ColMax
'Put a random number in a cell
Cells(r, c) = Int(Rnd * 1000)
Counter = Counter + 1
Next c

' Update the percentage completed.
PctDone = Counter / (RowMax * ColMax)

' Call subroutine that updates the progress bar.
UpdateProgressBar PctDone
Next r
' The task is finished, so unload the UserForm.
Unload UserForm1
End Sub

Sub UpdateProgressBar(PctDone As Single)
With UserForm1

' Update the Caption property of the Frame control.
.FrameProgress.Caption = Format(PctDone, "0%")

' Widen the Label control.
.LabelProgress.Width = PctDone * _
(.FrameProgress.Width - 10)
End With

' The DoEvents allows the UserForm to update.
DoEvents
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Progress Bar leerem Excel Discussion (Misc queries) 2 August 13th 08 05:16 PM
Progress Bar Jase Excel Discussion (Misc queries) 0 June 2nd 08 07:45 PM
Progress Bar Rockee052[_2_] Excel Programming 3 December 28th 03 11:30 PM
Progress Bar Help Malcolm Excel Programming 2 November 25th 03 01:57 PM
Progress Bar Help Malcolm Excel Programming 2 November 21st 03 02:29 PM


All times are GMT +1. The time now is 06:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"