Cannot get Application.Ontime to work

  • Good morning, I have formulated the following code to run the macro every 2 minutes, and if there is a change in cells 03: O11, send me an email with Table4. I can't get it to work, let's see if you can help me out, please.



    Thank you so much for everything

  • Hello,


    The code you posted is rather strange ...


    As long as you do have a macro stored is a standard module called : CellValueAutoIncr1


    you can test following event macro



    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Thanks for the code, and for the speed. But I don't have a stored macro, there is a standard module called: CellValueAutoIncr1. I just want to have this code.


    How could I modify it?


    Thank you very much again

  • Hello again,


    The keyword Target is to be used within a worksheet event macro ...


    For a standard macro, you should be using ActiveCell


    To be tested ...

    But this macro will NOT be triggered by a change ... you do have to run it ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Administrative Note:


    Your thread title is extremely weak. Please try to summarise what you are trying to achieve next time to give members some idea of what the query is about.

    Ali :)


    Enthusiastic self-taught user of MS Excel who's always learning!
    If anyone has helped you towards solving a problem, then you can thank them by clicking on the like icon bottom right.

    :!:Forum Rules

  • Sorry for not explaining clearly to me.

    I have an excel sheet fed from external data that is updated every 2 minutes. These external data are edited by me and if they meet certain conditions, they are placed in Table 4 (O3: X11). What I want is that every 2 minutes the VBA looks at Rank O3: O11, and if there is any news, send me an email. I have a normal excel sheet, not a macro, maybe that's why it doesn't work for me ...

  • Did you understand my comment about your thread title?

    Ali :)


    Enthusiastic self-taught user of MS Excel who's always learning!
    If anyone has helped you towards solving a problem, then you can thank them by clicking on the like icon bottom right.

    :!:Forum Rules

    Edited once, last by AliGW ().

  • Administrative Note:


    Your thread title is extremely weak. Please try to summarise what you are trying to achieve next time to give members some idea of what the query is about.

    Yes, you want me to change the thread title. But I can't change it now, I create a new thread with a more descriptive title?

  • No, I asked you to make sure that you use better titles in future.


    No, do not open a new thread on this issue.

    Ali :)


    Enthusiastic self-taught user of MS Excel who's always learning!
    If anyone has helped you towards solving a problem, then you can thank them by clicking on the like icon bottom right.

    :!:Forum Rules

  • Thanks for everything.


    I have an excel sheet called Sheet1, it is powered by external data that is updated every 2 minutes. These external data are edited by me and if they meet certain conditions, they are placed in Table 4 (O3: X11). What I want is that every 2 minutes the VBA looks at Rank O3: O11, and if there is any news, send me an email. I have a normal excel sheet, not a macro, maybe that's why it doesn't work for me ...

    I copy the code provided by Carim, but I don't get it to work. I would like to leave the VBA active so that it automatically checks every 2 minutes on sheet1 and if there is a change in O3: O11 automatically send me the email and continue executing the code for when there is another change to perform the same process again.


    Thanks in advance.

  • Did you save the workbook as an .xlsm workbook? If not, then you can't run it as a VBA-enabled workbook.

    Ali :)


    Enthusiastic self-taught user of MS Excel who's always learning!
    If anyone has helped you towards solving a problem, then you can thank them by clicking on the like icon bottom right.

    :!:Forum Rules

  • Hello,


    Thanks for your explanations ..


    Let's recap :


    1. An Excel sheet called Sheet1 updated every 2 minutes by external engine ( such as RTD )


    2. These external data get edited with formulas and they are replicated in Table 4 (O3: X11)


    3. Objective is to leave Excel opened and have a macro running so that it checks every 2 minutes on sheet1 any change in range O3: O11 and automatically send you an alert email.


    If my understanding is correct, the most important element is that you need an event to catch live update changes ...

    This is not possible, since Excel can catch a manual input by the user ...but it cannot ' see ' a cell change by an external live process ...


    Hope this clarifies

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Well ... an untested idea could be to design a trick ... ( which would require some lengthy coding )


    Say you have three distinct sheets in your workbook:


    1. Sheet1 and Sheet2 can be populated with the very same update as the one you are currently getting

    2. But, a macro could run every 2 minutes to 'freeze' the values only in Sheet2

    3. Sheet3 would then work out all the differences between Sheet1 and Sheet2

    4. Every 2 minutes, a worksheet calculate event could then check if all cells in Sheet3 are equal to 0 or not ...

    5. and, then, a macro could automatically send an alert email


    A lot of efforts ... to try to catch your live data updates ...;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Ok, thank you very much for the idea. I'm going to try to configure the trick you've told me, let's see how it goes

    Cheers and thank you again.

  • Good Morning. I am executing the code you put me above and I have a couple of doubts:

    - I have 3 pages as you told me to compare the data. I wanted to predict when I invoke the range (O3: O11), I have to tell you which page I want you to look at, right?

    - And then I just get him to send me the email once, I don't know how to make the macro run automatically every 2 minutes without me having to do anything.


    Thanks I hope you can help me.

  • If you only need an e-mail when at least one cell in O3:O11 changes, better to use event handlers to e-mail the new cell values when they change whenever they change rather than checking every 2 minutes if there could be changes more frequently than that. If these cells usually contain constants (NOT formulas), a .Change event handler would be best. If they contain formulas, a .Calculate event handler would be best but would require caching the previous values for comparison.

  • Since Real time data feeds do not trigger worksheet change event ...


    you could try : Application.OnData = "MyEmailMacro"

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

Participate now!

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