someone please get me out of this macro loop!

Joined
Aug 19, 2008
Messages
2
Reaction score
0
I have a continual looping macro (Transfer)- refer below- which I kick off with a button, running all the time. via the Application.OnTime, I trigger the next macro (TransferTallys) to run once. The problem is that it doesn't run once. It just loops and goes on and on even after the set time in the Application.OnTime argument is no longer valid. I have added the variable (Register1) that I set to 2 for 5 seconds to try to ensure that it won't run again, but to no avail. Can someone please tell me what I'm doing wrong?


Dim Register1
Sub Transfer()

--bulky code--

Application.OnTime EarliestTime:=TimeValue("X:XX:XX"), Procedure:="TransferTallys"
Application.OnTime EarliestTime:=Now() + TimeValue("00:00:5"), Procedure:="Transfer"

End Sub


Dim Register1
Sub TransferTallys()
'
' Macro1 Macro
' Macro recorded 8/6/2008 by tchilders
'
If Register1 = 1 Then

--more bulky code to tally and transfer data at end of day--

End If
Register1 = 2
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 5
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Register1 = 1
Run "Transfer"

End Sub
 

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