+ Reply to Thread
Results 1 to 8 of 8

Run Macro on cell change from streaming data (not manual user input)

  1. #1
    Registered User
    Join Date
    02-12-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007, 2013
    Posts
    89

    Run Macro on cell change from streaming data (not manual user input)

    I need a way to run macros when a cell change occurs as a result of stock data streaming via DDE link. All the scripts I've encountered so far have worked fine for running a macro when there is manual interaction with Excel. However I need the macro to run without me having to touch the keyboard or mouse. Is this possible?
    Last edited by Test123Test; 02-19-2012 at 05:21 PM.

  2. #2
    Registered User
    Join Date
    06-04-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Run Macro on cell change from streaming data (not manual user input)

    You'd have to run it on a timer basis. In other words monitor the value of the stock(s) every second and if it changes from the previous value then operate on it in the way that you want to.

  3. #3
    Registered User
    Join Date
    02-12-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007, 2013
    Posts
    89

    Re: Run Macro on cell change from streaming data (not manual user input)

    Hm, are you sure a timer-basis is the only way? The absolute best would be for it to run on a cell change.

  4. #4
    Registered User
    Join Date
    06-04-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Run Macro on cell change from streaming data (not manual user input)

    Agreed but I can't think of another way to monitor a cell otherwise. Sorry.

  5. #5
    Registered User
    Join Date
    02-12-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007, 2013
    Posts
    89

    Re: Run Macro on cell change from streaming data (not manual user input)

    No problem, do you have an example of how one could do this? Say I have a macro that I only want to run once the cell changes, but I will check every 1 second or so if the cell has actually changed...

  6. #6
    Registered User
    Join Date
    02-12-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007, 2013
    Posts
    89

    Re: Run Macro on cell change from streaming data (not manual user input)

    Okay I figured it out finally. I'm going to explain here in case someone have similar requests in the future:
    You have to use the Worksheet_Calculate() function if you want to run any macros automatically on cells updated by formulas or by streaming data. Worksheet_Change or anything else will NOT work, at least from my experience.

    Anyways I'll just post my entire code below. This code will make you able to run macros based on cell updates from formulas or streaming data, guaranteed:

    Please Login or Register  to view this content.
    Then you need to make a new module, name it "module1" or whatever. Enter this text
    Please Login or Register  to view this content.
    And you're good to go.
    Last edited by Test123Test; 02-15-2012 at 10:50 PM.

  7. #7
    Registered User
    Join Date
    02-12-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007, 2013
    Posts
    89

    Re: Run Macro on cell change from streaming data (not manual user input)

    *Double post*

  8. #8
    Registered User
    Join Date
    02-20-2012
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Run Macro on cell change from streaming data (not manual user input)

    hi,

    i was searching online for a solution to the exact same problem and found this post.
    Your code works perfectly! however, it seems that it only works twice.. could you help?

    Adrian

    Quote Originally Posted by Test123Test View Post
    Okay I figured it out finally. I'm going to explain here in case someone have similar requests in the future:
    You have to use the Worksheet_Calculate() function if you want to run any macros automatically on cells updated by formulas or by streaming data. Worksheet_Change or anything else will NOT work, at least from my experience.

    Anyways I'll just post my entire code below. This code will make you able to run macros based on cell updates from formulas or streaming data, guaranteed:

    Please Login or Register  to view this content.
    Then you need to make a new module, name it "module1" or whatever. Enter this text
    Please Login or Register  to view this content.
    And you're good to go.

+ 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