View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
wana be xl master wana be xl master is offline
external usenet poster
 
Posts: 6
Default VBA - before delete

Thanks Otto & Horward.
As Otto sugested the "undo" works perfectly.



"Otto Moehrbach" wrote:

Something like:
Dim NewValue as string
Dim OldValue as string
NewValue=Target.Value
Application.EnableEvents=False
Application.Undo
OldValue=Target.Value
'Do your check here
'Note that the old value is in the target cell. Leave it if you wish
or:
Target.Value=NewValue
Application.EnableEvents=True
Otto
"wana be xl master" wrote in
message ...
Hi there,

I'm using Workbook_SheetChange event. How can I capture the cell value
before user press delete button, then through the if statement if the
condition fails I want to put back the same value on the cell.

Appreciate any help.
Thanks,