Start Macro X minutes after opening worksheet

  • Re: Start Macro X minutes after opening worksheet


    Hi


    Have a look at the ontime method. Basically, if you open the file, then nominate the starting time to be now() + timevalue("00:02:00"), it will run the macro 2 minutes after the file is opened.



    HTH


    Tony

  • Re: Start Macro X minutes after opening worksheet


    GuyGadois,



    In the open event place the following line of code


    Code
    Application.OnTime now() + timevalue ("00:02:00"), "RoutineNameHere"
  • Re: Start Macro X minutes after opening worksheet


    Hi Guy


    You may want to pass the Time + TimeValue("00:02:00") to a variable so you can also cancel the OnTime Method via the Workbook_Close Event

  • Re: Start Macro X minutes after opening worksheet


    This would help me with one of my problems but I was just wondering if there would be a way for the macro to start after the datafeed finished versus the time setting. If the data builds beyond a 2 minute time level or drops in time, the macro could start early or waste time.

    [SIZE=2]I should change my name to STUMBED![/SIZE]

  • Re: Start Macro X minutes after opening worksheet


    oooh, good question. Could you base the macro starting on when a cell is greater than 0 (assuming the datafeed is inputing numbers)?


    Guy

  • Re: Start Macro X minutes after opening worksheet


    Quote from chrisxs5

    This would help me with one of my problems but I was just wondering if there would be a way for the macro to start after the datafeed finished versus the time setting. If the data builds beyond a 2 minute time level or drops in time, the macro could start early or waste time.



    Chrisxs5,


    You should be able to run a macro after your datafeed is done, by simply tracking which cells the datafeed fills. Now to me "datafeed" says that something else places a value into excel. So what you would do is afte the datafeed runs you would clear the datafeed cells. That way you can track when the datafeed process inserts new information. That's what the method that Norie suggested.


    If that's not the case and your datafeed inserts a datetime stamp and you are transfering the data to a table to be saved. All you would have to do is set you'r macro to run say every 30 seconds and the first thing would be to test the last timestamp and the current timestamp. If they're different continue if they're the same reset and restart in 30 seconds?

  • Re: Start Macro X minutes after opening worksheet


    Thats fantastic thinking, I will start on that right now. Thanks!

    [SIZE=2]I should change my name to STUMBED![/SIZE]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!