Aiysha
asked on
Time count
I want to keep a time count for my entire process. Its a macro that takes data from excel and goes to two different applications and then returns to excel.. so this is how I plan to do
note the initial time in a global variable1
note the final time in a global vaiable2
and at the end of the code print out a message with the difference in the time of variable2 and variable1
can someone please help me with this. This is what I have so far..And it doesn't work.
Dim InitialTime As Integer
Dim FinalTime As Integer
Dim TimeDifference As Integer
Sub Macro1()
IntialTime = Now()
FinalTime = Now()
TimeDifference = FinalTime - InitialTime
End Sub
Thanx for all the help
note the initial time in a global variable1
note the final time in a global vaiable2
and at the end of the code print out a message with the difference in the time of variable2 and variable1
can someone please help me with this. This is what I have so far..And it doesn't work.
Dim InitialTime As Integer
Dim FinalTime As Integer
Dim TimeDifference As Integer
Sub Macro1()
IntialTime = Now()
FinalTime = Now()
TimeDifference = FinalTime - InitialTime
End Sub
Thanx for all the help
Run this:
Sub happy()
MsgBox Timer
End Sub
to see what the timer displays.
Sub happy()
MsgBox Timer
End Sub
to see what the timer displays.
ASKER
Thanx a lot, I had already written the code before you posted your response.. This is what I have and it is very similar to your code.. The timer displays the time in seconds and I wanted it in minutes thats why I divided it by 60..
Dim InitialTime As Date
Dim FinalTime As Date
Dim TimeDifference As Date
Dim formatTime As Double
Sub Macro1()
InitialTime = Timer
FinalTime = Timer
formatTime = FinalTime - InitialTime
formatTime = formatTime / 60
MsgBox (formatTime)
End Sub
Dim InitialTime As Date
Dim FinalTime As Date
Dim TimeDifference As Date
Dim formatTime As Double
Sub Macro1()
InitialTime = Timer
FinalTime = Timer
formatTime = FinalTime - InitialTime
formatTime = formatTime / 60
MsgBox (formatTime)
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>Thanx a lot, I had already written the code before you posted your response.. This is what I have and it is very similar to your code.. The timer displays the time in seconds and I wanted it in minutes thats why I divided it by 60..
Dim InitialTime As Date
Dim FinalTime As Date
Dim TimeDifference As Date
Dim formatTime As Double
Sub Macro1()
InitialTime = Timer
FinalTime = Timer<<
Except that the Timer does not return a value of type Date but rather a single (number of seconds since midnight) You can use an Integer like calebS suggests, except that sometime just after 9:00AM you will get an overflow. You can of course use a Long.
Anthony
Dim InitialTime As Date
Dim FinalTime As Date
Dim TimeDifference As Date
Dim formatTime As Double
Sub Macro1()
InitialTime = Timer
FinalTime = Timer<<
Except that the Timer does not return a value of type Date but rather a single (number of seconds since midnight) You can use an Integer like calebS suggests, except that sometime just after 9:00AM you will get an overflow. You can of course use a Long.
Anthony
Dim InitialTime As Integer
Dim FinalTime As Integer
Dim TimeDifference As Integer
Sub Macro1()
IntialTime = Timer
FinalTime = Timer
TimeDifference = FinalTime - InitialTime
End Sub