Hello,
I have a cell value that updates throughout the day. It changes when the source data changes through a DDE link. How can I record the time of each update and each new value?
I've attached an excel doc as an example of what I am wanting to do. Cell A1 is the input, columns C & D have output values.
Please ask for clarification if necessary; thanks!
Greg
You can put this macro into the SHEET module to watch for changes in cell A1. If the value changes then it will be added to the log. If the value updates but is still the same value as the last entry in the log, it will not enter a new row.
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim LR As Long LR = Range("D" & Rows.Count).End(xlUp).Row If [A1] <> Range("D" & LR) Then Application.EnableEvents = False Range("D" & LR + 1).Value = [A1].Value Range("C" & LR + 1).Value = Now 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!)
JB;
I didn't think a DDE would trigger Worksheet_Change(). I thought it had to be a user or a macro to trigger it. Am I wrong?
Did you test it?
_________________
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!)
I'm having some trouble getting it to work, but am not sure yet what the cause is. The attached doc you had definitely did work, but I need a little more time to figure out why it isn't integrating into my larger workbook as expected. Will post update as soon as I have one.
No I haven't tested it. I have never set up a DDE, not even sure i know how.
Although I just reviewed Help and found this:
"Occurs when cells on the worksheet are changed by the user or by an external link."
I guess a DDE counts as an external link.
I learn something new every day.
I thought it would, the ws-change macro is triggered by ANY change in the sheet, and then I test the value of A1 against the last value in D to see if it's time for a new log entry.
If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
_________________
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!)
The DDE link isn't triggering it. I set it up to do a calculation with each new value, so that the DDE link value happens in A2 and A1 = A2 + 0, but that isn't doing it either.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks