Sub TimeStatusBar()
Dim dStart As Double
Dim dResult As Double
Dim bDisplayStatusBar As Boolean
bDisplayStatusBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
dStart = timer
TestStatusBar 1, False
dResult = timer - dStart
MsgBox Format(dResult, "0.00") & " seconds.", vbOKOnly
dStart = timer
TestStatusBar 1, True
dResult = timer - dStart
MsgBox Format(dResult, "0.00") & " seconds.", vbOKOnly
dStart = timer
TestStatusBar 5, True
dResult = timer - dStart
MsgBox Format(dResult, "0.00") & " seconds.", vbOKOnly
Application.DisplayStatusBar = bDisplayStatusBar
End Sub
Sub TestStatusBar(nInterval As Integer, bUseStatusBar As Boolean)
Dim lRow As Long
Dim lLastRow As Long
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets(1)
lLastRow = ws.Rows.Count
For lRow = 1 To lLastRow
If lRow Mod nInterval = 0 Then
If bUseStatusBar Then
Application.StatusBar = "Processing row: " & lRow & _
" of " & lLastRow & " rows."
End If
End If
Next
Application.StatusBar = False
Set ws = Nothing
End Sub
|