Progress Meter Error

TOM R

Well-known Member
Joined
Oct 7, 2006
Messages
731
Hello Members, The code below I'm trying to get to work errors.
with a Compile error: EndWith without With. What would be a remedy for this. Thanks in advance.

Code:
Sub UpdateProgress(Pct)
Dim c As Long
UserForm5.LabelProgress.Width = 0
a = 40000
For B = 1 To a
       c = B * a
       UserForm5.LabelProgress.Width = (B / a) * 400
 
 ' Update the Caption property of the Frame control.
UserForm5.FrameProgress.Caption = Format(PctDone, "0%")

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

   DoEvents
Next B

    Unload UserForm5
End With
End Sub


Regards, Tom
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi VoG, Thanks for repyling. If I take the endwith out I get ainvalid use of null error on line
Code:
UserForm5.LabelProgress.Width = PctDone * (UserForm5.FrameProgress.Width - 10)


You think, Maybe add: Dim as PctDone Long
Regards, Tom
 
Upvote 0
Hi VoG, Yes it sould be and I tried using that
Code:
Sub UpdateProgress(PctDone)
also get the same error. in
Code:
UserForm5.LabelProgress.Width = PctDone * (UserForm5.FrameProgress.Width - 10)


The code worked to a point I played around using other posts form the board but I'm not sure why it don't fire correctly.

Regards, Tom
 
Upvote 0
Hi VoG, I added
Code:
Dim PctDone as Long it
errors. If I keep
Code:
Dim PctDone as Long
the code fires with out error but the progress meter flickers in the userform with a the color advancing.

Code:
Sub UpdateProgress(Pct)
Dim c As Long
Dim PctDone As Long

UserForm5.LabelProgress.Width = 0
a = 10000
For B = 1 To a
       c = B * a
       UserForm5.LabelProgress.Width = (B / a) * 400
 
 ' Update the Caption property of the Frame control.
UserForm5.FrameProgress.Caption = Format(PctDone, "0%")

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

   DoEvents
Next B
    Unload UserForm5
End Sub

Regards Tom
 
Upvote 0
Hi I meant
Code:
Dim pct as Long
it will fire without the scrolling advance only flicker


Regards Tom
 
Upvote 0
Try with a diagnostic message:

Rich (BB code):
Sub UpdateProgress(PctDone As Long)
Dim c As Long
UserForm5.LabelProgress.Width = 0
a = 40000
For B = 1 To a
       c = B * a
       UserForm5.LabelProgress.Width = (B / a) * 400
 
 ' Update the Caption property of the Frame control.
UserForm5.FrameProgress.Caption = Format(PctDone, "0%")

' Widen the Label control.
MsgBox PctDone * (UserForm5.FrameProgress.Width - 10)
UserForm5.LabelProgress.Width = PctDone * (UserForm5.FrameProgress.Width - 10)

   DoEvents
Next B

    Unload UserForm5
End With
End Sub

Does it give a zero or negative value?
 
Upvote 0
Hi Vog i get a compile error with the End With

If I block that I get invalid use of Null Error

Regards Tom
 
Upvote 0
Sorry, I left the End With in by mistake.

With the line that errors commented out, what does the MsgBox return?

Code:
Sub UpdateProgress(PctDone As Long)
Dim c As Long
UserForm5.LabelProgress.Width = 0
a = 40000
For B = 1 To a
    c = B * a
    UserForm5.LabelProgress.Width = (B / a) * 400
    
    ' Update the Caption property of the Frame control.
    UserForm5.FrameProgress.Caption = Format(PctDone, "0%")
    
    ' Widen the Label control.
    MsgBox PctDone * (UserForm5.FrameProgress.Width - 10)
    'UserForm5.LabelProgress.Width = PctDone * (UserForm5.FrameProgress.Width - 10)
    
    DoEvents
Next B

Unload UserForm5
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,524
Messages
6,055,905
Members
444,832
Latest member
bgunnett8

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top