+ Reply to Thread
Results 1 to 4 of 4

Macro/function to take cell value at certain time and copy to other cell

  1. #1
    Registered User
    Join Date
    03-05-2007
    Posts
    3

    Macro/function to take cell value at certain time and copy to other cell

    I am trying to build a spreadsheet to manage my stock portfolio. The first time I open the sheet every morning, I want it to take the values of each stock in the "current share price" column and move them to a column called "previous day close". Is there a macro or another way to do this? Thanks for the help.
    Last edited by reinhardn; 06-23-2009 at 06:55 PM. Reason: clarification

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

    Re: Macro/function to take cell value at certain time and copy to other cell

    You want to write a Workbook_Open macro and insert it into the ThisWorkbook module. Set the macro to copy the values in the range of cells to be copied to the specific spot desired.

    It will occur every time you open the workbook. You might also want to add a "Last time ran" cell to enter the date when the workbook_open event last triggered. If you ever open the workbook a second time on the same day, you could have the first line of code checking that date, if the date there is TODAY's date, abort the copy routine. If not, copy the data and enter today's date into that cell.
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    03-05-2007
    Posts
    3

    Re: Macro/function to take cell value at certain time and copy to other cell

    Thanks for the help. I'm still having some trouble though. This is what I have in VB:

    Please Login or Register  to view this content.
    Cell D3 contains "=DATE()".

    The idea is to every morning (i.e. the first time the spreadsheet is opened each day, take the values from one column and move them to another. This is a spread sheet to track stock prices and values.

    I have no experience in VB, and only minimum experience in MATLAB. Any help is much appreciated.
    Thanks again.
    Last edited by reinhardn; 07-01-2009 at 11:56 AM.

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

    Re: Macro/function to take cell value at certain time and copy to other cell

    Try this instead:
    Please Login or Register  to view this content.
    Also, please edit your previous post and replace the QUOTE tags with CODE tags.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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