RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
I have a summary userformwith 2 DTPickers and 12 picture frames. When the user selects datesand clicks on a command button (Update Graphs), a graphing macro updates allthe graphs (*no problem with the graphing macro so will leave out*). Thistakes a couple seconds so I thought it'd be fun to include a status bar(ufProgress). Found one on the web and it works in large part. Theonly problem is that the status bar macro activates at every possible event(opening any one the DTPickers before eventually picking a date), evenclicking anywhere on the useform).
I image this is because of the "DoEvents" part of theFractionComplete code? But even if I comment that out the problem doesn't go away.
I only want the charts to reload when I click on either the Update Graphscommand button or some additional command buttons (e.g. I have command buttonsfor each month of the year)
Summary Userform Activation (*note there are some member variables prefixed by'm' the declarations of which I'm leaving out for brevity*)
FractionComplete Code
I image this is because of the "DoEvents" part of theFractionComplete code? But even if I comment that out the problem doesn't go away.
I only want the charts to reload when I click on either the Update Graphscommand button or some additional command buttons (e.g. I have command buttonsfor each month of the year)
Summary Userform Activation (*note there are some member variables prefixed by'm' the declarations of which I'm leaving out for brevity*)
Code:
Private Sub Userform_Activate()
[COLOR=#222222][FONT=Calibri]Dim arr1 As Variant
Dim i As Integer
[/FONT][/COLOR]
[COLOR=#222222][FONT=Calibri]Application.ScreenUpdating = False
ufProgress.LabelProgress.Width = 0
ufProgress.Show
arr1 = Array("Ni", "Co", "Cu", "Fe","S", "Ca", "Mg", "Si", "Mn","Na", "Al", "Zn")[/FONT][/COLOR]
[COLOR=#222222][FONT=Calibri]For miCount = LBound(arr1) ToUBound(arr1)
msDataIdentifier = msICP & arr1(miCount)
Call MakeChartSummary
FractionComplete ((miCount + 1) * 0.083) '0.083because I have 12 elements (1/12 = 0.083)
ufProgress.Repaint
Next miCount
[/FONT][/COLOR]
[COLOR=#222222][FONT=Calibri]Erase arr1[/FONT][/COLOR]
[COLOR=#222222][FONT=Calibri]Application.ScreenUpdating = True[/FONT][/COLOR]
[COLOR=#222222][FONT=Calibri]Unload ufProgress
[/FONT][/COLOR]
[COLOR=#222222][FONT=Calibri]End Sub
[/FONT][/COLOR]
FractionComplete Code
Code:
Sub FractionComplete(pctdone As Double)
With ufProgress
.LabelCaption.Caption = Format(pctdone * 100,"0.0") & "% Complete"
.LabelProgress.Width = pctdone * (.FrameProgress.Width)
End With
DoEvents
End Sub