Visualize a process in progress

Back

Any efficient Excel Application should be interactive. Dialog "between the application, the machine and the user must be easy and fluent.

You wil find hereabove a VBA routine to make easy the visualization of the progresses made by any of your VBA for Excel application.

Let us assign the names "Dataprocessing" to the User Form .

When the Userform is activated, it automatically activates the routine "Main" [1].

This routine represents two For ... Next structures, the second one being included in the first one [2].

This routine makes the red rectanlge greater until the maximum of 100%.

"Dataprocessing is the name of the Userform [3].



[1]-----------------------------------

Private Sub Userform_Activate()
Call Main
End Sub

[2]-----------------------------------

Sub Main()
AMax = 20000BMax = 2500
For a = 1 To 20000
For b = 1 To 2500
Counter = Counter + 1
Next b
PctDone = Counter / (AMax * BMax)
Call UpdateProgress(PctDone)
Next a
End Sub

[3]-----------------------------------

Sub UpdateProgress(Pct)
With DataProcessing
.FrameProgress.Caption = Format(Pct, "0%")
.LabelProgress.Width = Pct * (.FrameProgress.Width - 10)
.Repaint
End With
End Sub

--------------------------------------



Back