Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting the previous cell value after changing a cell

In VB I want to write a script that provides me with the row and column
information of a changed cell.
This can be done with
worksheet_change(ByVal Target as Range)

Target.row and Target.column provides the row and column information of
the changed cell. Target.value provides me with the new updated cell
value.

However, I also want to have the previous cell value of the changed
cell. How can I get this previous cell value?

Regards

wim.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Getting the previous cell value after changing a cell

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
Application.EnableEvents = False
vVal = Target.Value
Application.Undo
OldValue = Target.Value
Target.Value = vVal
Application.EnableEvents = True
End Sub

an alternate method would be to use a global variable and set it using the
SelectionChange event.

--
Regards,
Tom Ogilvy

"wim hoevenaren" wrote in message
...
In VB I want to write a script that provides me with the row and column
information of a changed cell.
This can be done with
worksheet_change(ByVal Target as Range)

Target.row and Target.column provides the row and column information of
the changed cell. Target.value provides me with the new updated cell
value.

However, I also want to have the previous cell value of the changed
cell. How can I get this previous cell value?

Regards

wim.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Getting the previous cell value after changing a cell

Another trick, but I don't have the code to hand, is to pre-pend the cell's
comment box with the cell's old value each time it changes. Then you can
have a journal of all changes to that cell. You could add a time stamp to
each entry if that's useful.


"wim hoevenaren" wrote in message
...
In VB I want to write a script that provides me with the row and column
information of a changed cell.
This can be done with
worksheet_change(ByVal Target as Range)

Target.row and Target.column provides the row and column information of
the changed cell. Target.value provides me with the new updated cell
value.

However, I also want to have the previous cell value of the changed
cell. How can I get this previous cell value?

Regards

wim.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
How can I copy a value from a cell and paste it into another cell while adding it to the previous value in that cell [email protected] Excel Worksheet Functions 2 November 7th 07 09:39 AM
auto populate cell based on previous cell drop down list selectio. PuzzledbyLists Excel Discussion (Misc queries) 2 September 11th 06 01:28 AM
formula, move to previous cell when the current cell=0 or empty osama amer Excel Discussion (Misc queries) 0 May 29th 06 12:18 PM
conditional cell format based on cell in same row, previous column tamiluchi Excel Worksheet Functions 7 May 3rd 06 04:11 PM
Select cell, Copy it, Paste it, Return to Previous cell spydor Excel Discussion (Misc queries) 1 December 30th 05 01:29 PM


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