![]() |
compare data evolution
Using the event Worksheet_Change, is that possible to compare the data in
cell before the change with the one which fire the macro ? I'm running under Excel 97 ! |
compare data evolution
Option Explicit
Private oldCell Const kTarget As String = "H10" Private Sub Worksheet_Activate() oldCell = ActiveCell.Value End Sub Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Target.Address(False, False) = kTarget Then MsgBox "Was " & oldCell & ", and is now " & Target.Value oldCell = Target.Value End If ws_exit: Application.EnableEvents = True End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address(False, False) = kTarget Then oldCell = Target.Value End If End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH RP (remove nothere from the email address if mailing direct) "Willow" wrote in message ... Using the event Worksheet_Change, is that possible to compare the data in cell before the change with the one which fire the macro ? I'm running under Excel 97 ! |
compare data evolution
Many thanks Bob
"Bob Phillips" wrote: Option Explicit Private oldCell Const kTarget As String = "H10" Private Sub Worksheet_Activate() oldCell = ActiveCell.Value End Sub Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Target.Address(False, False) = kTarget Then MsgBox "Was " & oldCell & ", and is now " & Target.Value oldCell = Target.Value End If ws_exit: Application.EnableEvents = True End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address(False, False) = kTarget Then oldCell = Target.Value End If End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH RP (remove nothere from the email address if mailing direct) "Willow" wrote in message ... Using the event Worksheet_Change, is that possible to compare the data in cell before the change with the one which fire the macro ? I'm running under Excel 97 ! |
All times are GMT +1. The time now is 02:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com