Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Newbie - cell contents B4 change event ?

Dear All

Apologies if you have answered this question a thousand times before
but I can't seem to find the answer, and my I can't seem to find th
right search term to get the answer. Must not be enough of a latera
thinker.

---------------

I would like to be able to store the contents of a cell before it i
changed and a worksheet_change event is triggered.

This will allow me to revert back to this value if a user presses
'Cancel' button on a form I'm developing.

The only thing I've been able to find that's close is th
'BeforeUpdate' event, but it seems this doesn't apply to worksheets
cells.

----------------

Any help would be much appreciated.

Thanks ... Walte

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Newbie - cell contents B4 change event ?

Walter,

The following code will do what you want in a basic format:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A1") = Target.Value
End Sub

It stores the value of the cell clicked on. When the cursor is moved to
another cell, A1 takes the initial value of *that* cell.

--

Julian Milano


"Walter " wrote in message
...
Dear All

Apologies if you have answered this question a thousand times before,
but I can't seem to find the answer, and my I can't seem to find the
right search term to get the answer. Must not be enough of a lateral
thinker.

---------------

I would like to be able to store the contents of a cell before it is
changed and a worksheet_change event is triggered.

This will allow me to revert back to this value if a user presses a
'Cancel' button on a form I'm developing.

The only thing I've been able to find that's close is the
'BeforeUpdate' event, but it seems this doesn't apply to worksheets /
cells.

----------------

Any help would be much appreciated.

Thanks ... Walter


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Newbie - cell contents B4 change event ?

Create a Static variable in which to store the value.

In the worksheet_change, use something like
====================
Static OldValue
Dim NewValue

OldValue = NewValue
NewValue = Target.value

===================
After the first time it runs, you'll have the old value and the new, changed
value.

You could also (or instead) store the oldvalue in a hidden cell somewhere,
so you can preserve its value between sessions.

As so:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldValue, NewValue

NewValue = Target.Value
OldValue = Range("the_Cell_I_Use_To_Store_This_Value").Value
' do whatever you want

' then store the current value
Range("the_Cell_I_Use_To_Store_This_Value").Formul a = NewValue

End Sub

--
Darren
"Walter " wrote in message
...
Dear All

Apologies if you have answered this question a thousand times before,
but I can't seem to find the answer, and my I can't seem to find the
right search term to get the answer. Must not be enough of a lateral
thinker.

---------------

I would like to be able to store the contents of a cell before it is
changed and a worksheet_change event is triggered.

This will allow me to revert back to this value if a user presses a
'Cancel' button on a form I'm developing.

The only thing I've been able to find that's close is the
'BeforeUpdate' event, but it seems this doesn't apply to worksheets /
cells.

----------------

Any help would be much appreciated.

Thanks ... Walter


---
Message posted from http://www.ExcelForum.com/



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
Newbie-Cell contents viewable but not printed Janet A. Thompson Excel Discussion (Misc queries) 0 September 10th 09 10:42 PM
Clearing Cell Contents / Worksheet_Change Event Grahame Coyle[_2_] Excel Worksheet Functions 5 September 5th 08 01:09 PM
Change Event on a Specific Cell Sashi Excel Worksheet Functions 3 July 20th 07 11:12 PM
cell change event gvm Excel Worksheet Functions 3 September 20th 05 04:50 AM
cell value change event alinasir Excel Worksheet Functions 1 August 30th 05 10:57 AM


All times are GMT +1. The time now is 02:33 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"