Triggering Macro hourly without onTime ?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
Thinking of ways I can trigger a macro hourly without using application.ontime
application.ontime can cause issues and I don't find it too reliable.

My idea was to have a cell containing current time =Now()-Today()

Then cells with a 1/0 flag for each hour

Worksheet_Change event with if statement like:
If time between 15:00 and 16:00 and flag is 0 then run macro and set flag to 1.

Any other way to approach this?
Macro I'm wanting to do is send an email hourly

Thanks for any input
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You will find that Now() doesn't update until the worksheet is recalculated, and if nothing is triggering a recalc it will just remain at the orignal value. One way you could do this is to create a web query to download the data from this site which is GMT time:
https://time.is/GMT
Then update the query to refresh every minute, you can then check the time against real GMT time although i expect the latency to be quite a few seconds.
I don't suppose this is any better than application ontime , but you could try it.
#
 
Upvote 0
You will find that Now() doesn't update until the worksheet is recalculated, and if nothing is triggering a recalc it will just remain at the orignal value. One way you could do this is to create a web query to download the data from this site which is GMT time:
https://time.is/GMT
Then update the query to refresh every minute, you can then check the time against real GMT time although i expect the latency to be quite a few seconds.
I don't suppose this is any better than application ontime , but you could try it.
#

Thanks I will give it a try
Though the worksheet is used all throughout the day and calculated multiple times per hour so I think the worksheet change could be Ideal
 
Upvote 0
Hi,
Thinking of ways I can trigger a macro hourly without using application.ontime
application.ontime can cause issues and I don't find it too reliable.

My idea was to have a cell containing current time =Now()-Today()

Then cells with a 1/0 flag for each hour

Worksheet_Change event with if statement like:
If time between 15:00 and 16:00 and flag is 0 then run macro and set flag to 1.

Any other way to approach this?
Macro I'm wanting to do is send an email hourly

Thanks for any input

Have you considered using a Windows Timer API like SetTimer ?
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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