Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Determining a previous cell value if deleted

Hi, this may seem strange but I want to be able to determine within the
Worksheet_change code what the value of a cell was if someone hit the delete
key to erase it. What I have done is setup different "modes" via macros that
set a defined name to a yes or no. If not in a certain mode, I don't want the
user to erase some fields. I know I could keep a hidden column with a shadow
copy that I pickup and restore the other from. In fact, I do have some of
that already but there is so much interaction be sheets and code, adding
additional columns almost drives one to drink as there is always somewhere
you forget.

Another option would be to set some sort of protect on fields from the
enabling/disabling macro that if someone does try a delete, my code would get
control and be able to inform the user of the error of their ways. I am
trying not to use the Excel locked cell scheme as most of the time the
protection will be off. This is just to try to keep users from shooting
themselves in the foot.
--
Randy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Determining a previous cell value if deleted

You could possibly do something like this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler
Dim i As Long
Dim v As Variant
Dim cell As Range
If Not Intersect(Target, _
Range("A1,B3:B10,C15,D2:D6")) Is Nothing Then
Application.EnableEvents = False
i = 0
ReDim v(0 To Target.Count - 1)
For Each cell In Target
v(i) = cell.Value
i = i + 1
Next
Application.Undo
' perform your checks and corrections

' restore values as appropriate
i = 0
For Each cell In Target
cell.Value = v(i)
i = i + 1
Next
End If
ErrHandler:
Application.EnableEvents = True
End Sub


Make value adjustments in the v array before restoring

--
Regards,
Tom Ogilvy

"Randy" wrote in message
...
Hi, this may seem strange but I want to be able to determine within the
Worksheet_change code what the value of a cell was if someone hit the

delete
key to erase it. What I have done is setup different "modes" via macros

that
set a defined name to a yes or no. If not in a certain mode, I don't want

the
user to erase some fields. I know I could keep a hidden column with a

shadow
copy that I pickup and restore the other from. In fact, I do have some of
that already but there is so much interaction be sheets and code, adding
additional columns almost drives one to drink as there is always somewhere
you forget.

Another option would be to set some sort of protect on fields from the
enabling/disabling macro that if someone does try a delete, my code would

get
control and be able to inform the user of the error of their ways. I am
trying not to use the Excel locked cell scheme as most of the time the
protection will be off. This is just to try to keep users from shooting
themselves in the foot.
--
Randy



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
deleted text character returning numbers when deleted. Trreborr09 New Users to Excel 3 April 11th 10 03:17 AM
Determining A Cell If it contain A string value Rob Excel Programming 7 August 26th 05 03:58 PM
Determining text in a cell ZABU Excel Programming 4 July 2nd 04 04:44 AM
Determining Cell Types in Excel - exceptions Tim Childs[_6_] Excel Programming 5 October 23rd 03 04:28 AM
Determining whether selected cell has value or formula? John Wirt Excel Programming 3 July 31st 03 04:19 AM


All times are GMT +1. The time now is 06:57 AM.

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

About Us

"It's about Microsoft Excel"