LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Statusbar

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FIX in Statusbar Stefi Excel Discussion (Misc queries) 2 July 30th 08 01:34 PM
Statusbar Gerald[_3_] Excel Programming 2 August 11th 06 06:43 PM
StatusBar Progress Silencer116 Excel Programming 0 April 20th 06 02:30 PM
Get the string of the statusbar RB Smissaert Excel Programming 6 May 17th 04 06:48 PM
StatusBar Msg? Tom Ogilvy Excel Programming 4 September 10th 03 02:32 PM


All times are GMT +1. The time now is 07:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"