+ Reply to Thread
Results 1 to 6 of 6

scheduled in the future to auto-run macro

  1. #1
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    scheduled in the future to auto-run macro

    hi,

    is it possible to run a macro on a specific date and time in the future?
    when the file is opened and the specified date and time is the same as the current date-time when it was opened
    or the date-time it was opened is past the date-time specified in the code

    for example:
    on Feb 28, 2018 at 10am
    automatically get the sum of G2 and H2 and put it in I2
    make the format in I2 bold and red color
    Last edited by k1dr0ck; 02-21-2018 at 04:30 AM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: scheduled in the future to auto-run macro

    Check this out: http://www.utteraccess.com/wiki/Schedule_a_Macro_to_Run

    It uses the windows task scheduler. It's a three-step process, you create a script. The script gives you a string to run itself when the task scheduler says to run it. The script runs the macro in the target workbook.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: scheduled in the future to auto-run macro

    thanks for the tip

    i think it runs all the code inside the workbook open sub
    i already have several code in my workbook open sub for my excel file
    i just need to run a portion of a code inside the workbook open sub for a certain scheduled date-time
    but this will run all the code

    im thinking is there a way in excel to compare dates
    (im ok if i can only compare date and not include the time)
    feb 28, 2018 and date the workbook is opened
    and using an IF STATEMENT if feb 28, 2018 is same as the date it was opened
    or the date it was opened is past feb 28, 2018
    then i can run my desired code inside the IF STATEMENT
    Last edited by k1dr0ck; 02-21-2018 at 10:29 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: scheduled in the future to auto-run macro

    edit:
    so i found this, it works for me

    Please Login or Register  to view this content.
    Last edited by k1dr0ck; 02-22-2018 at 09:26 PM.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: scheduled in the future to auto-run macro

    I prefer to design my reports so I can open them and work on them without macros running, so that's why the "target" reports don't have on open events.

    The scripts, on the other hand, do run code with an on open event. The scripts open the target report and run the specified macro (usually I call this Executive) which sometimes runs other macros to refresh data, set pivot table filters etc.

    Going back even one more step, the windows task scheduler opens the script and since it has an on open event, it runs the macro in the target workbook.

    There is a point in setting up the task scheduler where you have to enter in the command to run. The script provides this string so you can copy and paste it at that point in the task scheduler setup.

    The task scheduler does nice things like "Run every other Sunday night at 10 PM." I don't have to figure out how to do that.

  6. #6
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: scheduled in the future to auto-run macro

    i can see the advantages of using the script and task scheduler for other more complex job
    thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Auto Fill dates in the future
    By Judylily in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-31-2017, 09:20 AM
  2. Need help with auto-filling dates in the future in consecutive columns
    By tarheelbobcat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2014, 10:25 PM
  3. auto delete all data based on a future date
    By dawondr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2013, 02:01 PM
  4. Scheduled Macro
    By dreicer_Jarr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2013, 08:15 PM
  5. Replies: 1
    Last Post: 10-31-2012, 10:11 PM
  6. [SOLVED] Run a Macro via a Scheduled Time
    By John in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2006, 06:00 PM
  7. scheduled macro - more efficient way to do it?
    By bondcrash in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-15-2005, 05:39 AM

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