Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - before delete
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, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - before delete
"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, Use Worksheet_SelectionChange. I've not tested, but I expect that Worksheet_SelectionChange occurs before the user does ant hanky panky in a selection.. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - before delete
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, |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below | Excel Programming |