Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progress Bar - Code transfers to 'Form1' code & stops execution 1

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
GB
I HAVE looked at loads of examples & explanations 'out-there' but I'm still no wiser. I have a looping procedure that will take a file name
Code:
"SWB" (Source WorkBooK0
from cells in Row B
Code:
For c = 2 To SLC 'Column B to End Column of Source data - Source Last Column
and I want that file name to appear in a Label in a Progress Bar, so I have put this code next:-
Code:
            UserForm1.Label1.Caption = SWB
        
            UserForm1.Show
At which point it goes to the code in 'Forms; UserForm1'
Code:
Private Sub UserForm_activate()
    Call Main
End Sub
that I obviously got from elsewhere(!).

Code:
Sub Main()
    Dim Counter As Integer
    Dim PctDone As Single
    
    Application.ScreenUpdating = False
            Counter = Counter + 1

        PctDone = Counter / ILC
        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

End Sub

And that's where it appears to stop! If I manually Close down (X) the Progress Bar Form, I get back to the code.

(I have already declared 'ILC' & 'SWB' as 'Public' in the Declarations section, so I don't think I have a problem with them.)

What I need to know is how to get back into my running code to do the rest of the looping, updating the Progress Bar each time.

I hope it's just my ignorance and someone can point out where I'm going wrong.

Many thanks (in advance)

Des.
 
Hopefully UserForm1 is NOT modal ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Mr Stupid doesn't even understand that question :(

Er, possibly as it's sitting in the 'Forms' folder. It went there automatically when I went "Insert; Userform".

Des.
 
Replace this:
UserForm1.Show
with this:
UserForm1.Show vbModeless

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
By Golly!! I'd NEVER have got that. It's about quitting time so I can go home happy.

Many thanks :) :)

Des.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top