Thread: Timer Event
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Saxman[_5_] Saxman[_5_] is offline
external usenet poster
 
Posts: 23
Default Timer Event

On Mon, 12 Dec 2005 09:40:02 -0600, Chip Pearson wrote:

All the code should be in Module1, or any regular code module,
as you already have it. What error do you get?


Thanks for your patience. I have got the following to run. I have also
added a keyboard shortcut to 'StartTimer'. I altered the time to 5 seconds
(so I wouldn't have to wait too long).

If I wanted to copy/paste, say 10 times, then all I would need to do is to
add the last routine 10 times and modifying the sheet numbers accordingly?

I would need to add "sheet1" at the end of each routine to copy the new
data. (I left it out for simplicity).

How can I stop the macro once it has started, as it loops forever?

Thanks again. It might be one small step for me, but one hell of a step to
my progress!

.................................................. ........................

Public RunWhen As Double
Public Const cRunIntervalSeconds = 5 '5 seconds
Public Const cRunWhat = "The_Sub"
Sub StartTimer()

RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _
schedule:=True
End Sub

Sub The_Sub()
Range("A1:A5").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
StartTimer

End Sub