+ Reply to Thread
Results 1 to 11 of 11

DDE-link problem

  1. #1
    Registered User
    Join Date
    08-22-2009
    Location
    stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    DDE-link problem

    hi all
    i would like some help with DDE-linking.
    i want to link my stock portfolio to a spreadsheet to make various calculations on historic performance.
    my problem is that it is the same cell thats get updated whenever a change occurs, so that there is no history.

    let's say i put the DDE-link in cell A1, i would like B1 to be filled with that value
    and then when the value changes i would like B2 to be filled with the new value
    and the next time B3, and so on.

    can anyone help me?

    thanks
    nyrn2k

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: DDE-link problem

    Hello nyrn2k,

    Because the link will only update the cell, you need a macro that will trigger when cell "A1" changes to create the history.
    Please Login or Register  to view this content.
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Make any custom changes to the macro if needed at this time.
    6. Save the macro in your Workbook using CTRL+S
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    08-22-2009
    Location
    stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: DDE-link problem

    thanks

    i followed your instructions but i could only get it to work once when A1 was empty and i filled it with a number.
    then when i changed A1 nothing happened...
    do i need to do something else aswell, or am i doing something wrong?

    i have another question;
    how do i make a cell show the last value in a row?

    thanks for your help

    /nyrn2k

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: DDE-link problem

    Hello nyrn2k,

    That was my error, not yours. I rewrote the code and this works correctly. Delete the previous macro and replace it with this version.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-22-2009
    Location
    stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: DDE-link problem

    thank you

    it worked beautifully, exactly what i wanted, when i changed the value of A1 manually.
    however, it didn't work when i put a link in A1, then the change didn't trigger...

    and also, the new question again:
    how do i make a cell show the last value in a row?

    /nyrn2k
    Last edited by nyrn2k; 08-24-2009 at 01:45 AM.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: DDE-link problem

    A DDE-link will not invoke the Change event, you will need to use the Calculate event but that in itself is open to error (ie the Calculate event can be invoked by all manner of events not simply a DDE update - trapping the DDE update is not as trivial as it first seems)... if you run a search on the forum on DDE you should find a lot of examples - possible workarounds.

    see: http://www.excelforum.com/excel-work...matically.html

    In the above I make mention of a couple of ideas mentioned to me by Colin Legg (MS Excel MVP) which might prove useful to you...
    Last edited by DonkeyOte; 08-24-2009 at 02:25 AM.

  7. #7
    Registered User
    Join Date
    08-22-2009
    Location
    stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: DDE-link problem

    hi
    I don't get it, is what is Calculate event?

    The DDE-link works, but it updates only the cell where i put it.

    The code Leith posted works for creating a row of history whenever A1 is changed, but only when i change it manually, not with DDE.
    How do I make that happen?

    and also; how do I link a cell to the last filled cell in a row?

    /nyrn2k

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: DDE-link problem

    Hello nyrn2k,

    Here is the code for the Worksheet_Calculate event. Delete the previous macro and add this one to the sheet that has the DDE liink in "A1".
    Please Login or Register  to view this content.
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Make any custom changes to the macro if needed at this time.
    6. Save the macro in your Workbook using CTRL+S

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: DDE-link problem

    You might want to disable events ...
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Registered User
    Join Date
    08-22-2009
    Location
    stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: DDE-link problem

    now it updates properly,
    but if i put formulas in row C referring to the values coming in in row B, row B gets filled up immediately.

    is it possible to put the DDE-link in the code? would that solve anything?

  11. #11
    Registered User
    Join Date
    08-22-2009
    Location
    stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: DDE-link problem

    thanks for all your help!

    how would i make excel do this for multiple different stocks, but only check/update latest price once every ten minutes?
    Last edited by nyrn2k; 09-14-2009 at 08:58 AM.

+ 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