+ Reply to Thread
Results 1 to 2 of 2

Use Ontime Only Monday through Friday

Hybrid View

prescient Use Ontime Only Monday... 11-14-2008, 04:40 PM
Bob Phillips Private Sub Workbook_Open()... 11-14-2008, 07:35 PM
  1. #1
    Registered User
    Join Date
    11-14-2008
    Location
    Nashua
    Posts
    19

    Use Ontime Only Monday through Friday

    I have a macro that needs to run monday through friday at both 5 AM and 7 PM. Since I know very little about VBA my plan was to simply run it as stated below. However I have realized that the data I need will updated on friday night but will not updated until monday morning. Is there any way that I can specify to pause if the first part of the Macro runs on friday and wait for the second part to run on monday? I appreciate any help I can get with this. Thank you!


    Private Sub Workbook_Open()
        Application.OnTime TimeValue("19:00:00"), "CopyClose"
        Application.OnTime TimeValue("05:00:00"), "CopyOpen"
    End Sub

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284
    Private Sub Workbook_Open()
    Dim nTime As Double
    
        nTime = Date + TimeValue("19:00:00")
        If Weekday(Date) = 1 Then nTime = nTime + 1
        If Weekday(Date) = 7 Then nTime = nTime + 2
        Application.OnTime nTime, "CopyClose"
        
        nTime = Date + 1 + TimeValue("05:00:00")
        If Weekday(Date) = 6 Then nTime = nTime + 2
        If Weekday(Date) = 7 Then nTime = nTime + 1
        Application.OnTime TimeValue("05:00:00"), "CopyOpen"
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1