+ Reply to Thread
Results 1 to 3 of 3

understanding a progress bar

Hybrid View

  1. #1
    Registered User
    Join Date
    09-24-2003
    Posts
    62

    understanding a progress bar

    I have downloaded the code from http://j-walk.com/ss/excel/tips/tip34.htm

    I have created the userform or the progress bar, but am having a difficult time inderstanding where the codes go.

    in my case I have a userform("reports") where users use checkboxes to determine the type of report they want to create. and then click the commandbutton1("Create") that, depending on which check boxes are true, runs other modules.

    what I have done is have commandbutton1_click have ProgressBar.show instead of depending on which check boxes are true. and the code I use now in commandbutton1_click replace "call main" in the code below.
    Private Sub UserForm_activate()
        Call Main
    End Sub
    below would just be what ever module the userform_activate runs from above code.

    Sub Main()
    '   Inserts random numbers on the active worksheet
        Dim Counter As Integer
        Dim RowMax As Integer, ColMax As Integer
        Dim r As Integer, c As Integer
        Dim PctDone As Single
        
        If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
        Cells.Clear
        Application.ScreenUpdating = False
        Counter = 1
        RowMax = 100
        ColMax = 25
        For r = 1 To RowMax
            For c = 1 To ColMax
                Cells(r, c) = Int(Rnd * 1000)
                Counter = Counter + 1
            Next c
            PctDone = Counter / (RowMax * ColMax)
            With UserForm1
                .FrameProgress.Caption = Format(PctDone, "0%")
                .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
            End With
    '       The DoEvents statement is responsible for the form updating
            DoEvents
        Next r
        Unload UserForm1
    End Sub
    and this should be at the at the end of ever module that could be ran from the userform_activate

    Sub ShowDialog()
        UserForm1.LabelProgress.Width = 0
        UserForm1.Show
    End Sub
    but I can't seem to get it right. Any ideas?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Zygoid,

    What exactly are you having problems with?

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    09-24-2003
    Posts
    62
    hi leith !

    well, I was getting just a white progress bar form. after reading a bit more about progress bars, I think I figured out why. the progress bar codes are more for loops. I am not using a loop. just that I have a userform, that when i click the commandbutton1 to create the report it runs many modules depending on which checkboxes are checked on the form.

    the more checkboxes that are true the longer it takes to create the report.

    there are 3 frames, frame1 has 4 checkboxes, frame2 has 13 and frame3 has 5. depends on which frame has which checkboxes true, depends on which modules run, i have a total of 36 that can run for 1 report.

+ 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