I think I worded the title right lol?
So I have a macro already coded that operates in any time interval I want based on Sub StartTimer() RunWhen Now + the serial string blah blah. It works great. My problem is that I need it to run on the minute based on the time of day? Does that make sense? Not just a minute from when I start the timer. So say right now it is 12:30:30 being Hour/Minute/Second. So if I started the timer now it wouldn't operate until 12:31:00 and continue on every minute after that.
I just need it to be a bit more accurate as it is recording open and close stock price on the minute. Yes I realize I could just wait with my hand on the button for the minute to change but bare with me here lol. I am trying to recreate charts on the Metatrader platform in excel using live data and I need very specific prices. Here is the entire macro below.
So I have a macro already coded that operates in any time interval I want based on Sub StartTimer() RunWhen Now + the serial string blah blah. It works great. My problem is that I need it to run on the minute based on the time of day? Does that make sense? Not just a minute from when I start the timer. So say right now it is 12:30:30 being Hour/Minute/Second. So if I started the timer now it wouldn't operate until 12:31:00 and continue on every minute after that.
I just need it to be a bit more accurate as it is recording open and close stock price on the minute. Yes I realize I could just wait with my hand on the button for the minute to change but bare with me here lol. I am trying to recreate charts on the Metatrader platform in excel using live data and I need very specific prices. Here is the entire macro below.
Code:
Public RunWhen As DoublePublic Const cRunIntervalSeconds = 60
Public Const cRunWhat = "Mess"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
End Sub
Sub Mess()
Application.ScreenUpdating = False
With ThisWorkbook.Sheets("Analysis Data")
.Range("A3").Value = Time
.Range("C1") = .Range("C3") + 1
Set Crng = .Range("B6:AQ6")
Set Prng = .Range("$B$9").End(xlUp).Offset(1, 0)
Crng.Copy
.Range("B8").PasteSpecial Paste:=xlPasteValues
.Range("B8:AQ8").Copy
.Range("B9:AQ9").Insert Shift:=xlDown
.Range("B6000:AQ6000").Delete Shift:=xlUp
Application.ScreenUpdating = True
End With
StartTimer
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=False
End Sub