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.
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 theicon 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!)
thanks so much....
i was almost there, but I made mistake with my target...so mine didnt work...
thanks so so much!!!
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 theicon 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!)
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 theicon 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!)
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.
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
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
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks