+ Reply to Thread
Results 1 to 13 of 13

Automatically Save and Copy Values Daily with a Date Stamp

  1. #1
    Registered User
    Join Date
    12-31-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    10

    Automatically Save and Copy Values Daily with a Date Stamp

    Hi this is my first time posting in here, and hopefully I am in the right place. I have an excel file that I use to track all my financial investments. The file is already set up with a query to retrieve stock prices when I refresh the document.

    I would like to be able to open up the document, and store the closing price of the stock(s) with a date in the next column over. With this information I can graph weekly, monthly annually, or any time period I want.

    I have been searching for a couple of hours now, and I could not find anything similar to this. I would think this is a pretty common idea for many people tracking their investments with Excel, so if it has been covered perhaps someone can point me in the right direction.

    I don't have any programming experience in excel so as detailed of an explanation as possible would be much appreciated. Thanks in advance.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-31-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    Okay so I have uploaded a partial portion of the spreadsheet to this post. Basically the stock prices are updated whenever I refresh the document, and I would like to pull values from F24 and F5 of "Mutual Fund Current Values" to the hypothetical columns I created in Past closing values. I would just like a simple column with the date and closing price for each individual stock price.

    Hopefully this clears it up a little bit. Thanks in advance.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-31-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    royUK: Did that spreadsheet help or is it too confusing?

  5. #5
    Registered User
    Join Date
    12-31-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    I am trying one last bump. Does anyone know where to start on this?

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    What do you want to trigger this update to the Past Closing Values sheet? A button on the sheet? Automatic in some way you can imagine?

    If there is already an entry for today and it gets triggered again, what do you want to happen? Delete the old and replace with new? Abort? Allow duplicate date entries?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    I think that this is what you want. Probably add a button to run the code.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-31-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    Roy, that was just what I was looking for! It took me about an hour or so to figure out your code (I have a TINY bit of experience) and modify it to what I needed.

    Thanks so much for the code and the response. I left you a positive reputation feedback.

    JBeaucaire: I think you might have read a little to much into my post. I think what I was asking for was maybe easier than I made it sound. Thanks for looking and trying.

    On another note, I would like to add a "button" that will refresh the query (Control + Alt + F5) and THEN run the Macro. Is there a way to do this?

    Roy, I was looking at your website, and I think tomorrow I will try to tackle creating a table of contents.

    Thanks for all of you help. There is so much to Excel that I have yet to learn.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    If you add the button then call each macro, I would use the Controls ToolBox button
    Please Login or Register  to view this content.
    [

  10. #10
    Registered User
    Join Date
    12-31-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    Hi Roy,

    That explanation works. I was also looking for how to simulate the keystrokes of Control + Alt + F5 but found:

    Please Login or Register  to view this content.
    Which seems to do the trick. I have created a button that will Refresh the Query, and then transfers the days current closing values. The problem that I am having is that updating the quesry takes some time, and the values are copied before they can be updated. Hopefully that makes sense. I tried putting in a wait command

    Please Login or Register  to view this content.
    but that does not work. Do you have any idea on how to fix this?




    On another note, I have tried to modify your code for the macro I reference above which I call CalculatePercentage. Basically, it takes the values from the previous column to find the percentage change from the day before (example (C4-C3)/C3). I am having some trouble with it, and I would greatly appreciate it if you could let me know what I am doing wrong. I have copied it below. I have also attached a dummy sheet if you dont understand what I am asking.

    Please Login or Register  to view this content.
    Finally, I am trying to create a table of contents page and I was following the suggestion on your website, by simply hyperlinking the worksheets. I am trying to go for a simplified document and hide the worksheets at the same time. If they are hidden, they cannot be hyperlinked. Is there a setting I missed, or do you have any suggestions on how to do a TOC in the way that I described?

    Thanks for your patience and help. I hope I am not asking for too much.
    Attached Files Attached Files
    Last edited by cckal; 01-06-2010 at 02:26 AM.

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    You cannot access a hidden worksheet so hyperlinks will not work. Maybe you could simply hide the tabs themselves from the Tools Menu->Options->View->Sheet tabs.

    Your Wait code should delay by 5 seconds is this long enough.

    In the CalculatePercentage code your variable is COL,not Cold. If you use Option Explicit you will avoid such errors. I'm not sure what you are doing with it, it's not clear from the example

  12. #12
    Registered User
    Join Date
    12-31-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    Hi Roy,

    I got the tabs hidden, but I am still having problems with my other two previous points. I will try to clearly explain them.

    So this is a financial document used for tracking my stocks. The stocks are in sheets DABBX and DASBX. When I refresh the query (this is the first thing in my macro) , the values update on those sheets.

    On the sheet called "holdings" I have the current value of the stocks in the J'th column that are referenced to the DABBX and DASBX sheets. I had a lot of other personal information on that sheet that I have deleted.

    I am using the sheet "Daily Closings" to track the closing price of the stock which are in columns B and D. That is what I had you write the initial macro for me. I wanted take that one step further by calculating the percentage change from the previous day and this is done in columns C and D. I have inputed equations to determine these values, but I would like the macro do do it for me.

    So to sum this up, the queried stocks are updated, which are reference into the "Holdings" sheet which the macro reads and write the values to Daily Closings.

    The problem is that the stock prices DABBX and DASBX are updated but are not updated fast enough to be taken from the macro and written onto "Closing Values" even with a 5 second wait.

    Furthermore, my macro to determine the percentage change is not working and I do not know why.

    I hope I made this clear. I tried to make my dummy sheet as simple as possible.

    Any help would be greatly appreciated.

    Please Login or Register  to view this content.
    Where all the code that I added from your original macro that relates to the percentage calculation is:


    Please Login or Register  to view this content.
    Where the last line essentially says: Percentage = (B4-B3)/B3 but it is set up so that it varies based on the loop and the location I am calling. The problem either lies in the equation, or how I defined PrevRw or PrevCol.
    Attached Files Attached Files
    Last edited by cckal; 01-07-2010 at 04:27 AM.

  13. #13
    Registered User
    Join Date
    12-31-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Automatically Save and Copy Values Daily with a Date Stamp

    I feel like the error in my code is something small, and it is bugging me a lot. Would anyone mind looking at the code in my previous post? Thanks in advance.

+ 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