How to automatically start Macro at a set time?

DayTraderKevin

New Member
Joined
Dec 23, 2022
Messages
35
Office Version
  1. 365
Platform
  1. Windows
I found this somewhere online and placed it in ThisWorkbook...

Private Sub Workbook_Open()

Runs a macro at 6:30 AM
Application.OnTime TimeValue("18:20:01"), "GetMyData"

End Sub

It sort of works. My macro is programmed to run every minute...

myTimer = Now + TimeValue("00:01:00")

When I run Workbook_Open, it will start the macro, but sometimes the macro won't adhere to running once a minute, but goes into an immediate loop. Sometimes it will run correctly only once a minute. I'm not sure what's causing the inconsistency.

Is there a better (more consistent) way to auto-start a macro?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Update: Application.OnTime works perfectly if the file is closed and re-opened. Not sure why.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,148
Messages
6,123,307
Members
449,095
Latest member
Chestertim

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top