tdcolumbia
New Member
- Joined
- Apr 3, 2015
- Messages
- 5
Thanks in advance for any help provided.
Hello, I am kinda of a newbie who has learned everything I currently know about Excel VBA through Google. I have now reached a state where I don't know how to ask Google what I want. So.....
I am trying to run a Logsheet spreadsheet which calls DDE data at the top of every hour + 5 seconds then at 12:00:10 AM I copy the data to a blank file, clear the existing logsheet and start over at 1am......
Here is the procedure I am using currently:
----------------------------------------------------------------------------------
Sub CURRENT_TIME()
Workbooks("REPORTS.xlsm").Worksheets("DailyReports").Range("TEST2") = TESTCOUNTER
Workbooks("REPORTS.xlsm").Worksheets("DailyReports").Range("TEST1") = Loopcount
currenthour = Hour(Now) 'Capture current hour'
If currenthour = 23 Then 'If 11:xx pm indexs to 12:05 am for next run'
nextrun = 0 'sets next run time to be an hour of 0-12 am'
Else
nextrun = (currenthour + 1) 'after lookinga at current time indexes time by 1 hour'
End If
TimeToRun = TimeSerial(nextrun, 0, 5) 'sets the time to run procedure nextrun = hou, 0 min past the hr, 5 sec'
Application.OnTime Earliesttime:=TimeToRun, procedure:="GETWWDATA" 'calls procedure at specfic time (timetorun) to run application'
Application.OnTime Earliesttime:=TimeValue("12:00:10 AM"), procedure:="EndOfDayTasks" ' Runs End of Day Report task at 10 seconds past Midnight
End Sub
-----------------------------------------------------------------
The problem I am having is that each Application.OnTime command ends up running multiple times in the Second that I am calling them to run.
My guess is that my computer processor is so fast that it can run the command multiple times within a second.
How do I get this to only run once?
Again, thanks for any help.
Hello, I am kinda of a newbie who has learned everything I currently know about Excel VBA through Google. I have now reached a state where I don't know how to ask Google what I want. So.....
I am trying to run a Logsheet spreadsheet which calls DDE data at the top of every hour + 5 seconds then at 12:00:10 AM I copy the data to a blank file, clear the existing logsheet and start over at 1am......
Here is the procedure I am using currently:
----------------------------------------------------------------------------------
Sub CURRENT_TIME()
Workbooks("REPORTS.xlsm").Worksheets("DailyReports").Range("TEST2") = TESTCOUNTER
Workbooks("REPORTS.xlsm").Worksheets("DailyReports").Range("TEST1") = Loopcount
currenthour = Hour(Now) 'Capture current hour'
If currenthour = 23 Then 'If 11:xx pm indexs to 12:05 am for next run'
nextrun = 0 'sets next run time to be an hour of 0-12 am'
Else
nextrun = (currenthour + 1) 'after lookinga at current time indexes time by 1 hour'
End If
TimeToRun = TimeSerial(nextrun, 0, 5) 'sets the time to run procedure nextrun = hou, 0 min past the hr, 5 sec'
Application.OnTime Earliesttime:=TimeToRun, procedure:="GETWWDATA" 'calls procedure at specfic time (timetorun) to run application'
Application.OnTime Earliesttime:=TimeValue("12:00:10 AM"), procedure:="EndOfDayTasks" ' Runs End of Day Report task at 10 seconds past Midnight
End Sub
-----------------------------------------------------------------
The problem I am having is that each Application.OnTime command ends up running multiple times in the Second that I am calling them to run.
My guess is that my computer processor is so fast that it can run the command multiple times within a second.
How do I get this to only run once?
Again, thanks for any help.