PDA

View Full Version : clock in statusbar



lior03
01-04-2006, 09:43 AM
hello
i am trying to insert a line in a macro that will tell how much time elapsed fro, starting the macro to the end.all this shuld be doen through the statusbar.

Sub vin()
Dim x As String
Application.StatusBar = Format("hh / mm / ss")
x = InputBox("enter criteria to filter:data should be like ????", _
"moshe's filter", Default:="filter criteria goes here")
If x = Empty Then Exit Sub
With Worksheets("projects")
.Select
.Range("c1").AutoFilter _
field:=3, _
Criteria1:=x
Application.StatusBar = ""
End With
End Sub


i know i am missing something...
thanks

mvidas
01-04-2006, 09:50 AM
Hi moshe,

The best thing to do is have a variable that records your starting time, then send that to a function to display your elapsed time. Using your example formatting:Sub vin()
Dim x As String, StartTime As Double
StartTime = Now
UpdateElapsedTime StartTime
x = InputBox("enter criteria to filter:data should be like ????", _
"moshe's filter", Default:="filter criteria goes here")
If Len(Trim(x)) = 0 Then GoTo EndSub
UpdateElapsedTime StartTime
With Worksheets("projects")
.Select
.Range("c1").AutoFilter Field:=3, Criteria1:=x
End With
EndSub:
Application.StatusBar = False
End Sub
Function UpdateElapsedTime(ByVal StartingTime As Double) As Boolean
Application.StatusBar = Format(Now - StartingTime, "hh / mm / ss")
End FunctionThough for this example you wouldn't need to show elapsed time. Keep in mind that updating the statusbar like this does take some runtime, so you need to decide if you really want to have this in there. Also, to clear it, set it = False, rather than = "".

Matt