M
Mark Worthington
I have read with interest many forum posts about the use of Public
variables in Excel VBA.
I was blithely unaware of variable lifetimes (coming from a Fortan/VAX
background) and came a cropper recently. I now try to do without
Public declarations, directly pass the variables from one sub to the
next & declare everything within the procedure.
However, my question is how to do this with UserForms. For instance, I
have a Chart progress UserForm which has the activation following code
:
Private Sub UserForm_Activate()
Dim PctDone As Single
PctDone = Active_Chart / cochar
With UF_UpdateAllCharts_Progress
.FrameProgress.Caption = ForMat(Round(PctDone, 2), "0%")
.LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
.Repaint
End With
If PctDone >= 1 Then
Unload UF_UpdateAllCharts_Progress
Else
UF_UpdateAllCharts_Progress.Hide
End If
End Sub
I call the UserForm as normal from a procedure,
UF_UpdateAllCharts_Progress.Show
I need to transfer the Active_Chart and cochar integer values from the
module … the only way I can think is to use Public variables.
Can anyone please point me in the right direction?
Cheers,
Mark
variables in Excel VBA.
I was blithely unaware of variable lifetimes (coming from a Fortan/VAX
background) and came a cropper recently. I now try to do without
Public declarations, directly pass the variables from one sub to the
next & declare everything within the procedure.
However, my question is how to do this with UserForms. For instance, I
have a Chart progress UserForm which has the activation following code
:
Private Sub UserForm_Activate()
Dim PctDone As Single
PctDone = Active_Chart / cochar
With UF_UpdateAllCharts_Progress
.FrameProgress.Caption = ForMat(Round(PctDone, 2), "0%")
.LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
.Repaint
End With
If PctDone >= 1 Then
Unload UF_UpdateAllCharts_Progress
Else
UF_UpdateAllCharts_Progress.Hide
End If
End Sub
I call the UserForm as normal from a procedure,
UF_UpdateAllCharts_Progress.Show
I need to transfer the Active_Chart and cochar integer values from the
module … the only way I can think is to use Public variables.
Can anyone please point me in the right direction?
Cheers,
Mark