How do I write a macro for keeping time?

T

TomK76

I would like to write a macro that will work in Excel 2003 that would enable
a user to use keys on the keyboard (F5 and F6 for example) to start and stop
a timer function and return the amout of time elapsed between
keystrokes...like a stop watch. I would like to use this to track machine
downtime.
 
B

Bob Phillips

Private nTime As Double

Public Sub SetKeys()
Application.OnKey "{F5}", "StartTimer"
Application.OnKey "{F6}", "StopTimer"
End Sub

Public Sub StartTimer()
nTime = Timer
End Sub

Public Sub StopTimer()
MsgBox Timer - nTime & "secs"
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top