Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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,




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:20 PM
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 Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 06:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"