ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problems using Worksheet_Change (https://www.excelbanter.com/excel-programming/395727-problems-using-worksheet_change.html)

Peres from Brasil

Problems using Worksheet_Change
 
Does someone knows if exist any way of getting the old value in this:

Private Sub Worksheet_Change(ByVal Target As Range)
€˜ for the new data coming is easy:
New_data = Target.Value

€˜And about the old data into the cell€¦. Is there something like:

Old_data = Target.Old_data
End Sub

Thanks a lot
Peres


Gary''s Student

Problems using Worksheet_Change
 
You will need to "remember" the old value by storing it in a static variable.
--
Gary''s Student - gsnu200737


"Peres from Brasil" wrote:

Does someone knows if exist any way of getting the old value in this:

Private Sub Worksheet_Change(ByVal Target As Range)
€˜ for the new data coming is easy:
New_data = Target.Value

€˜And about the old data into the cell€¦. Is there something like:

Old_data = Target.Old_data
End Sub

Thanks a lot
Peres


Peres from Brasil

Problems using Worksheet_Change
 
Tanks very, very much, you help me in 2 ways because I didnt know how to
create a variable that could be seen inside the subs...
Tanks again!

"Halim" wrote:

Peres,

This will help you:
Option Explicit
Private Old_data
Private New_data
'

Private Sub Worksheet_Change(ByVal Target As Range)
New_data = Target.Value
MsgBox "Change from '" & Old_data & "' to '" & New_data & "'"
End Sub

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

--
Regards,

Halim



"Gary''s Student" wrote:

You will need to "remember" the old value by storing it in a static variable.
--
Gary''s Student - gsnu200737


"Peres from Brasil" wrote:

Does someone knows if exist any way of getting the old value in this:

Private Sub Worksheet_Change(ByVal Target As Range)
€˜ for the new data coming is easy:
New_data = Target.Value

€˜And about the old data into the cell€¦. Is there something like:

Old_data = Target.Old_data
End Sub

Thanks a lot
Peres



All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com