M
Matts
Hi,
I've taken this code from one of the samples available on another website.
In the below sample code, how do i determine/translate the "# of items to
process"
for my project.
There are upto 17 diff worksheets on my current project & on opening the
workbook there are linking/updations/calculations that are done automatically.
With the code as it is, the status bar work fine, but the progress indicator
runs quicker than the actual time that it takes for the entire updation to
happen.
Thsi needs to work cos I've decide to stop the screen flicker as well.
I need the status bar to be in sync with the actual time that the updation
takes.
please advice
Code being used >
Option Explicit
Sub TestBar()
Dim MyTot As Long, i As Long, j As Integer
Application.ScreenUpdating = False ' speed up the macro
Sheets(1).Select ' has records to process
MyTot = 5000 ' # of items to process
i = 0 ' sets startvalue for your index
While i < MyTot ' start your While .. Wend, Do .. Loop or For .. Next
i = i + 1 ' increase your index / activate your next item
StatBar i, MyTot, "Processing", True ' display statusbar
For j = 1 To 10000: Next j ' remove this line from your code to
speed up processing
' do something ...
' do something else ...
Wend ' start processing next item
Application.StatusBar = False ' remove statusbartext
End Sub
Sub StatBar(MyIndex As Long, MyTotal As Long, MyText As String, InclPercent
As Boolean)
Const NumBars As Integer = 30 ' # of characters in the bar
Const FillChar As String * 1 = "•" ' alt+0149 or try out your own character
Const DoneChar As String * 1 = "»" ' alt+0187 or try out your own character
Dim PctDone As Integer, FBar As Integer, BBar As Integer, BarText As String
If MyIndex Mod CInt((MyTotal * 0.01)) <> 0 Then Exit Sub
' previous line speeds up the macro by not updating the statusbar for
every single record
If MyText <> Empty Then BarText = MyText & " " Else BarText = Empty
PctDone = CInt((MyIndex / MyTotal) * 100)
FBar = CInt(PctDone / 100 * NumBars)
BBar = NumBars - FBar
If InclPercent Then
BarText = BarText & " " & PctDone & " % "
End If
Application.StatusBar = BarText & Application.Rept(DoneChar, FBar) &
Application.Rept(FillChar, BBar)
End Sub
I've taken this code from one of the samples available on another website.
In the below sample code, how do i determine/translate the "# of items to
process"
for my project.
There are upto 17 diff worksheets on my current project & on opening the
workbook there are linking/updations/calculations that are done automatically.
With the code as it is, the status bar work fine, but the progress indicator
runs quicker than the actual time that it takes for the entire updation to
happen.
Thsi needs to work cos I've decide to stop the screen flicker as well.
I need the status bar to be in sync with the actual time that the updation
takes.
please advice
Code being used >
Option Explicit
Sub TestBar()
Dim MyTot As Long, i As Long, j As Integer
Application.ScreenUpdating = False ' speed up the macro
Sheets(1).Select ' has records to process
MyTot = 5000 ' # of items to process
i = 0 ' sets startvalue for your index
While i < MyTot ' start your While .. Wend, Do .. Loop or For .. Next
i = i + 1 ' increase your index / activate your next item
StatBar i, MyTot, "Processing", True ' display statusbar
For j = 1 To 10000: Next j ' remove this line from your code to
speed up processing
' do something ...
' do something else ...
Wend ' start processing next item
Application.StatusBar = False ' remove statusbartext
End Sub
Sub StatBar(MyIndex As Long, MyTotal As Long, MyText As String, InclPercent
As Boolean)
Const NumBars As Integer = 30 ' # of characters in the bar
Const FillChar As String * 1 = "•" ' alt+0149 or try out your own character
Const DoneChar As String * 1 = "»" ' alt+0187 or try out your own character
Dim PctDone As Integer, FBar As Integer, BBar As Integer, BarText As String
If MyIndex Mod CInt((MyTotal * 0.01)) <> 0 Then Exit Sub
' previous line speeds up the macro by not updating the statusbar for
every single record
If MyText <> Empty Then BarText = MyText & " " Else BarText = Empty
PctDone = CInt((MyIndex / MyTotal) * 100)
FBar = CInt(PctDone / 100 * NumBars)
BBar = NumBars - FBar
If InclPercent Then
BarText = BarText & " " & PctDone & " % "
End If
Application.StatusBar = BarText & Application.Rept(DoneChar, FBar) &
Application.Rept(FillChar, BBar)
End Sub