+ Reply to Thread
Results 1 to 8 of 8

Run macro x no. of times if file closed for x no. of days.

  1. #1
    Registered User
    Join Date
    10-11-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    7

    Run macro x no. of times if file closed for x no. of days.

    I have a macro that runs automatically at a certain time each day. If the workbook is closed it obviously will not run.

    Is there a way to get it to run for example-if the workbook was closed for x number of days, the macro runs x number of times on Workbook_Open?

    I know I can use the task manager to run excel but would like a solution if the computer gets shut off.

    Thanks

  2. #2
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Run macro x no. of times if file closed for x no. of days.

    Try before close to enter a date and time in a cell.
    Then use workbook. open to determen the difference between the date in the cell and todays date (date when you open the file again).
    When you get a number then set it so it runs the macro the number times

    So this will have a macro save a date before close and check before open
    If the date is the same as today (when you open the workbook back) then just exit sub

  3. #3
    Registered User
    Join Date
    10-11-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Run macro x no. of times if file closed for x no. of days.

    Thanks will try that and update after a few days testing

  4. #4
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Run macro x no. of times if file closed for x no. of days.

    Ok Good Luck!

  5. #5
    Registered User
    Join Date
    10-11-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Run macro x no. of times if file closed for x no. of days.

    That has worked. Thanks.

  6. #6
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Run macro x no. of times if file closed for x no. of days.

    It would be a good idia, if you could paste the code you used in here if some else will be looking for a simular answer

  7. #7
    Registered User
    Join Date
    10-11-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Run macro x no. of times if file closed for x no. of days.

    Good idea

    For the workbook close event

    Please Login or Register  to view this content.
    For the workbook open event

    Please Login or Register  to view this content.
    If you see anything wrong here let me know but it seems to work okay. I have it running twice for each day hence the *2 bit

  8. #8
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Run macro x no. of times if file closed for x no. of days.

    Thanks
    I bet it will be useful

+ 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