Repeat several macros every 24h without having to restart the workbook.

luzikedy

New Member
Joined
May 23, 2014
Messages
44
Hi All,

Below is the code I use to trigger few macros in different time intervals. Currently I have to remember to close and open workbook at least once in 24 hours otherwise the macros will not perform very important tasks.

I was searching though forums and I was trying to implement things I found, but I couldn't get anything to work properly.

What should I add/change in order to have these macros repeated at given times everyday?

Private Sub Workbook_Open()


RaportShifts


Application.OnTime TimeValue("06:15:00"), "Send_Report_Email"
Application.OnTime TimeValue("10:00:00"), "Update_Links"
Application.OnTime TimeValue("14:15:00"), "Send_Report_Email"
Application.OnTime TimeValue("16:00:00"), "Update_Links"
Application.OnTime TimeValue("22:15:00"), "Send_Report_Email"

End Sub



Thx!
 

wellsr

Board Regular
Joined
May 16, 2015
Messages
130
To keep the macros triggering indefinitely, you'll want to place the Application.OnTime triggers at the bottom of your other macros, as well. For example, keep your Workbook_Open sub the same, but in your Send_Report_Email macro, add the following line to the bottom:
Code:
Application.OnTime TimeValue("06:15:00"), "Send_Report_Email"
Follow the same process for each of your other macros.
 

luzikedy

New Member
Joined
May 23, 2014
Messages
44
Thx for help. The whole concept works, but because I have the same macro executed 3 times a day I had to replicate the macro, so I have something link this now:

Application.OnTime TimeValue("06:15:00"), "Send_Report_Email1"
Application.OnTime TimeValue("10:00:00"), "Update_Links1"
Application.OnTime TimeValue("14:15:00"), "Send_Report_Email2"
Application.OnTime TimeValue("16:00:00"), "Update_Links2"
Application.OnTime TimeValue("22:15:00"), "Send_Report_Email3"
 

Forum statistics

Threads
1,081,617
Messages
5,360,049
Members
400,565
Latest member
Tommy O

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top