+ Reply to Thread
Results 1 to 6 of 6

Run Macro once day when opened

  1. #1
    Registered User
    Join Date
    10-24-2014
    Location
    london
    MS-Off Ver
    2010
    Posts
    7

    Run Macro once day when opened

    Hi fellas, im new to the forum so thanks in advance.

    I need a VBA code that will run a macro once a day no matter how many times the spreadhseet is opened. I would like to avoid having to adjust any cells manually, as the spreadhseet I am creating is going to beused not by me, but for a number of individuals.

    Im a beginer in macro/VBA and still in early stages of learning this art. I have seen some threads here on the topic, but non have been able to give me the help i need.

    The sheet is sheet1

    The name of the macro is Mem_Ref





    Any help will be deeply apprecated.

    Many thanks,

    Byron

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Run Macro once day when opened

    This will check cell A1 to see if it has already been ran today, if not then it amends A1 to store todays date, saves the workbook and then runs the macro (obviously A1 may not be convenient for your sheet so adjust that to anywhere free.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-24-2014
    Location
    london
    MS-Off Ver
    2010
    Posts
    7

    Re: Run Macro once day when opened

    Thanks for the quick response. Very much appreciated.

    I do however have a question. When i run the code above, the macro Mem_Ref runs as usual, meaning the data i want to keep will be replaced by new data. Also, G1 (which i changed from A1) is not filling in with a date.

    I need my macro to be limited to be run once a day upon being opened. How can i limit the amount of times the code is run on a single day?

    Perhaps the time stamp of the last time the macro was used on cell e.g. G2. If today = the last time the macro was run, then dont run macro. If yesterday was the last time the macro was run, then run macro.


    regards,

    Byron
    Last edited by marcelo.bayas; 10-24-2014 at 12:23 PM.

  4. #4
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Run Macro once day when opened

    Its running the macro everytime because G1 is not being completed. Best bet is to debug and see exactly what happens when G1 is meant to be set.

  5. #5
    Registered User
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Run Macro once day when opened

    I've tested the Macro shared by pjwhitfield and it's working fine. The Range isn't referring to any sheet. So when you open your workbook are you actually on the same sheet? IF not retry the below code and name your sheet as appropriate

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-24-2014
    Location
    london
    MS-Off Ver
    2010
    Posts
    7

    Re: Run Macro once day when opened

    Thank you ever so much fellas.

    I had my g1 as a =today() and not as a value.

    I'll probably be posting here again Im sure. you guys are awesome, great stuff.


    Byron

+ 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. Use a macro to extract cell data from opened workbook to new opened workbook
    By BrianTFC in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2014, 01:35 PM
  2. How to set a Global Macros so that it gets opened every time an excel file is opened?
    By pericopericone in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2013, 05:53 AM
  3. [SOLVED] stop excel file opened as read only if already opened by another u
    By bobm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-09-2011, 08:45 AM
  4. Excel 2007 : Macro when workbook is opened
    By colins in forum Excel General
    Replies: 5
    Last Post: 02-22-2010, 01:27 PM
  5. Run macro when worksheet is opened
    By MLT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-11-2005, 02:05 PM

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