ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scheduled Macros in Excel (https://www.excelbanter.com/excel-programming/328420-scheduled-macros-excel.html)

Kee

Scheduled Macros in Excel
 
Is there a way to time an Excel Macro (that will copy data from a specified
row and paste data into another worksheet), 3 times daily?.,,, for example
11am, 1pm and 4pm.


Bob Phillips[_7_]

Scheduled Macros in Excel
 
You can use OnTime, but this will only set the next scheduled time.

What you could do is check the time and set the next accordingly, something
like

Sub myProc()
Dim nTime As Date
If Time < TimeValue("11:00:00") Then
nTime = TimeValue("11:00:00")
ElseIf Time < TimeValue("13:00:00") Then
nTime = TimeValue("13:00:00")
ElseIf Time < TimeValue("16:00:00") Then
nTime = TimeValue("16:00:00")
Else
nTime = 1 - Now() + TimeValue("11:00:00")
End If

Application.OnTime nTime, "myProc"
End Sub

and start the myProc off and running.

--
HTH

Bob Phillips

"Kee" wrote in message
...
Is there a way to time an Excel Macro (that will copy data from a

specified
row and paste data into another worksheet), 3 times daily?.,,, for

example
11am, 1pm and 4pm.





All times are GMT +1. The time now is 01:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com