• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Automatically macro run if system time every 10 minutes between start time to end time VBA excel

Hi,

I am working on Excel 2013,

I need the automatic macro run if system time every 10 minutes between start time to end time VBA excel

>>> use code - tags <<<
Code:
VBA Code
'In Workbook events:
Private Sub Workbook_Open()
    Call Update
End Sub

'In a Module:
Dim RunTimer   As Date
Sub Update()
    RunTimer = Now + TimeValue("00:00:20")
    Application.OnTime RunTimer, "Update"
   
    'Do Something Your Code
    MsgBox "Data Update.", vbInformation
End Sub

eg:
Excel Open
start time is 9:30 AM
end time is 5:00 PM
show the "msgbox" every 10 minutes

Kindly help me, thanks in advance
 
Last edited by a moderator:
Hi, you must check the end time like this :​
Code:
        Const T = #12:10:00 AM#
    If Time + T < #5:00:00 PM# Then
        RunTimer = Now + T
        Application.OnTime RunTimer, "Update"
    End If
Do you like it ? So thanks to click on bottom right Like !​
 
Thank You for your reply, But not work (not showing the message box), I am doing something wrong that I don't know.....

>>> as You've noted <<<
>>> use code - tags <<<

Code:
VBA Code
'In Workbook events:
Private Sub Workbook_Open()
    Call Update
End Sub

'In a Module:

Dim RunTimer As Date
Sub Update()
    'Windows Taskplanner for my daily updates
    'Starting Time to End Time - Automatically Run a Macro Every X Minutes or Hours
    Const T = #12:10:00 AM#
    If Time + T < #5:00:00 PM# Then
        RunTimer = Now + T
        Application.OnTime RunTimer, "Update"
    End If
  
    'Do Something Your Code
    MsgBox "Data Update.", vbInformation
End Sub
 

Attachments

  • Starting Time to End Time - Automatically Run a Macro Every X Minutes or Hours 1.xlsm
    14.2 KB · Views: 2
Last edited by a moderator:
Back
Top