+ Reply to Thread
Results 1 to 9 of 9

Thread: when the data in a cell changes, automatically take a record of this change data

  1. #1
    Registered User
    Join Date
    09-19-2009
    Location
    LONDON
    MS-Off Ver
    Excel 2003
    Posts
    8

    when the data in a cell changes, automatically take a record of this change data

    Hi All,

    I am not sure how to go about creating a spreadsheet that does this:

    I have a number much like a stock market index which is in cell A1 for instance,
    and this data changes every second,

    And I wish to create my spreadsheet to automatically make a record of this change value and populate it at the last available blank row, so ultimately, I have a full history of how this number changes during the course of time.


    say

    5450 in cell A1
    a second later, it changes to 5430
    and so I want to populate 5430 to A2

    and then another second, it changes from 5430 to 5470
    and so i want to populate 5470 to A3 and so forth....



    does anyone know how to do it?


    thanks
    Last edited by cartedor; 09-20-2009 at 07:42 AM.

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: when the data in a cell changes, automatically take a record of this change data

    This is a sheet macro, right-click the sheet tab, select VIEW CODE and insert this code behind the sheet into the window that appears:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("A1")) Is Nothing Then
            Application.EnableEvents = False
            Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("A1").Value
            Application.EnableEvents = True
        End If
    End Sub
    _________________
    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
    09-19-2009
    Location
    LONDON
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: when the data in a cell changes, automatically take a record of this change data

    thanks so much....

    i was almost there, but I made mistake with my target...so mine didnt work...
    thanks so so much!!!

  4. #4
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: when the data in a cell changes, automatically take a record of this change data

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)
    _________________
    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!)

  5. #5
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: when the data in a cell changes, automatically take a record of this change data

    You had a followup question? Please post it here for the forum.
    _________________
    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!)

  6. #6
    Registered User
    Join Date
    09-19-2009
    Location
    LONDON
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: when the data in a cell changes, automatically take a record of this change data

    Hi, Yes I do have a follow up question...

    i figured out how to make column A and Column B to repeat the above action.

    However, the tricky thing is that with the event change function...this works brilliantly if someone is to put a new number into Cell A1...
    but unfortunately if the data in Cell A1 is a formula, which generates a number, so its changing every second, the code does not do record it automatically.

    I have been looking at the Event Calculate, perhaps thats the function i need or a combination of the two function event change and event calculate.

    Alternatively....if i can get this code to do it every second or every other second to just make a record of the number in a certain cell - in this example its cell A1.

    Is there anything similar like that?

    Please advise, thanks.

  7. #7
    Registered User
    Join Date
    09-19-2009
    Location
    LONDON
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: when the data in a cell changes, automatically take a record of this change data

    i think they might be it....

    I swap column A and B around so i have time on column A and value on Column B...this seems to work...




    Private Sub Worksheet_Calculate()
    Worksheet_Change Range("B1")
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B1")) Is Nothing Then
    Application.EnableEvents = False
    Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("A1").Value
    Application.EnableEvents = True
    Application.EnableEvents = False
    Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("B1").Value
    Application.EnableEvents = True
    End If
    End Sub

  8. #8
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: when the data in a cell changes, automatically take a record of this change data

    cartedor,

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.

    Thanks.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    05-06-2011
    Location
    Bognor
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: when the data in a cell changes, automatically take a record of this change data

    Hello, how do I get this function to record the changes horizontally rather than vertically?
    Last edited by whitlos; 11-18-2011 at 05:20 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.2.0