ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting pre edit values (https://www.excelbanter.com/excel-programming/335643-getting-pre-edit-values.html)

APS

Getting pre edit values
 
I am using Worksheet_Change to identify edits on a sheet and highlight the
changes where appropriate by testing on the Target object.

What I really need is to be able to retrieve the value of the cell before
the edit is done, i.e. if the cell is changed from 2 to 3 I need to retieve
the value 2.

Is this possible??

Tnanks in advance for any help on this.

Tom Ogilvy

Getting pre edit values
 
In the change event,
store the current value of the changed cell
Disable Events
Application.Undo
store the value of the changed cell (this is the 2 in your example)
write the first value you stored
enable events

--
Regards,
Tom Ogilvy

"aps" wrote in message
...
I am using Worksheet_Change to identify edits on a sheet and highlight the
changes where appropriate by testing on the Target object.

What I really need is to be able to retrieve the value of the cell before
the edit is done, i.e. if the cell is changed from 2 to 3 I need to

retieve
the value 2.

Is this possible??

Tnanks in advance for any help on this.




APS

Getting pre edit values
 
Thanks Tom, neet solution works wonderfully. Would be good if 'pre edit
value' was an attribute on the Target object though. Next release maybe.

"Tom Ogilvy" wrote:

In the change event,
store the current value of the changed cell
Disable Events
Application.Undo
store the value of the changed cell (this is the 2 in your example)
write the first value you stored
enable events

--
Regards,
Tom Ogilvy

"aps" wrote in message
...
I am using Worksheet_Change to identify edits on a sheet and highlight the
changes where appropriate by testing on the Target object.

What I really need is to be able to retrieve the value of the cell before
the edit is done, i.e. if the cell is changed from 2 to 3 I need to

retieve
the value 2.

Is this possible??

Tnanks in advance for any help on this.






All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com