Link to home
Start Free TrialLog in
Avatar of llawrenceg
llawrencegFlag for United States of America

asked on

Start, Stop an Restart Timer

I have a call answering system that starts off  with a timer set for every 5 sec to be able  to copy and paste the caller client number fron the Windows clipboard when the phone rings to Cells B3.Then I have the current date and time put in Cell C3.
I would like to stop the timer when Cell C3  is filled and Restart when Cell H3 is filled to capture the next call.
Cells B3-H3 are filled and then copied down so that B3-H3 are blank for data from the next caller
The process repeats itsellf for each call
I start off with a workbook Open:
Private Sub Workbook_Open()
Application.OnTime TimeValue(Now + TimeValue("00:00:05")), "CheckClipboard"
End Sub

Then in a Standard Module:

Sub CheckClipboard()

Dim MyData As DataObject
Dim AllStr As String
Dim ShortStr As String

Set MyData = New DataObject
On Error Resume Next
MyData.GetFromClipboard
AllStr = MyData.GetText
ShortStr = Left(AllStr, 4)

If (ShortStr = "Plan") Then
   Worksheets(1).Activate
   ActiveSheet.Cells(3, 2).Value = AllStr
   MyData.SetText ""
   MyData.PutInClipboard
   ActiveSheet.Cells(3, 3).Value = Now
End If

Application.OnTime TimeValue(Now + TimeValue("00:00:05")), "CheckClipboard", 
End Sub

Open in new window

Avatar of clarkscott
clarkscott
Flag of United States of America image

Instead of calling the "CheckClipboard" procedure from the Timer, write a small sub to call first.


Function CheckFirst()

'--- if your condition is not good to run
exit function
'---- if your condition is good to run
call CheckClipboard
end function

'--- this will bypass your checkclipboard sub if you don't want it to run.

Scott C
     
ASKER CERTIFIED SOLUTION
Avatar of clarkscott
clarkscott
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dmitry_n
dmitry_n

Why not use something like http://www.xnotestopwatch.com