I'm working on excel sheet using VBA: I'm trying to test a progress bar. I already completed the design, as shown below:
Below the userForm
code:
'PLACE IN YOUR USERFORM CODEPrivate Sub UserForm_Initialize()#If IsMac = False Then'hide the title bar if you're working on a windows machine. Otherwise, just display it as you normally would Me.Height = Me.Height - 10 HideTitleBar.HideTitleBar Me#End IfEnd Sub
Below the Module
code:
'PLACE IN A STANDARD MODULESub LoopThroughRows()Dim i As Long, lastrow As LongDim pctdone As Singlelastrow = Range("A" & Rows.Count).End(xlUp).Row'(Step 1) Display your Progress BarufProgress.LabelProgress.Width = 0ufProgress.ShowFor i = 1 To lastrow'(Step 2) Periodically update progress bar pctdone = i / lastrow With ufProgress .LabelCaption.Caption = "Processing Row " & i & " of " & lastrow .LabelProgress.Width = pctdone * (.FrameProgress.Width) End With DoEvents'--------------------------------------'the rest of your macro goes below here'''--------------------------------------'(Step 3) Close the progress bar when you're done If i = lastrow Then Unload ufProgressNext iEnd Sub
When I run the code, I get this error:
And when I press on Debug
, it highlights on this:
ufProgress.LabelProgress.Width = 0
More information
UserForm name is (ufProgress) , The label that in the upper left of UserForm that will be used to display the text indicating the status name (LabelCaption) ... And the frame on UserForm name (FrameProgress ) .. Finlay , the another label, that going to grow progresses indicator name (LabelProgress) ..
Any advice ...
Kind Regards