Capture Excel cell change without SelectionChange event?

Hello, I am trying to capture the change (difference) of a cell value before and after a change is made. When a user manually changes one cell at a time I have been using the Worksheet_SelectionChange to capture the cells initial value to track the changes but these values can also be updated by a macro that does not select the cell before making the changes.

Is there any way to track these changes without having my code select each cell to be changed first?
LVL 1
wipnavAsked:
Who is Participating?
 
Rory ArchibaldConnect With a Mentor Commented:
I don't really understand what the SelectionChange event has to do with anything.
The usual way to test against the previous value in a change event is to store the value of the cell in a variable, use Application.Undo to revert to the previous value, and then test against the stored value. If your changes are the result of code, I suspect that won't work unless the changing code provides its own Undo routine.
0
 
Rory ArchibaldCommented:
You should be using the Worksheet_Change event, not the SelectionChange event. :)
0
 
wipnavAuthor Commented:
I am, sorry for the confusion.

My procedure adds a comment the cell being changed that is supposed to report the difference in the values (new value - previous value). This code is embedded in the Worksheet_Change event. I was using the Worksheet_SelectionChange event to get the previous value.

My question is how do I get the previous value without using the Worksheet_SelectionChange event?
0
 
wipnavAuthor Commented:
Hmm, undo does sound like a better solution. This all started out just tracking changes on one cell manually and setting a variable to the value of the cell in the SelectionChange event to be used in comparing to the Change event worked fine, but for what I need to do now, using undo would be better.

I will use that for when the changes are made manually and just set a global variable from my other procedures that change the cell values before I make the changes then pass them to the Worksheet_Change event.

Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.