A Simple Timer

  • Thread starter Thread starter Jay Fincannon
  • Start date Start date
J

Jay Fincannon

I have a Worksheet_Change event that does different things depending
on which column is involved. I would like to set the current time
somewhere when I start entering data and again when I finish.
Entering 'End' triggers a sort routine. I just need to know the time
interval between starting and ending entries.

I know I could look at a clock both times, but that's not as much fun.
 
Jay,

Try something like

Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub Worksheet_Change(ByVal Target As Range)
Dim StartTick As Long
Dim EndTick As Long
StartTick = GetTickCount()
'
' your code here
'
EndTick = GetTickCount()
MsgBox "Elapsed time (milliseconds): " & _
Format(EndTick - StartTick, "#,##0")
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Back
Top