Get value of a cell before it is deleted.


Posted by Steve Mathews on July 11, 2001 4:05 PM

Is it possible to get the value of a cell in code when it is deleted? For example, cell "B1" has "Steve" and I select it and delete it. Can I find out that "Steve" was in that cell before it was deleted? I already have code in the Worksheet -> Change event which is called after the cell is deleted and I can't find a way to get the previous value of the cell.



Posted by Damon Ostrander on July 11, 2001 10:51 PM

Hi Steve,

I suggest you use the SelectionChange event and the Change event. Since one has to select a cell in order to delete it manually (I assume it is being done manually rather than by VBA), if you save cell contents each time a cell is selected, you will always have the previous value of the deleted cell. Just save it in a variable that is global in the worksheet's event code area so that both event routines can access it, and declare it as Variant so it can accept any type of value a cell can contain.

Happy computing.

Damon