How to get original cell value prior to change event?

Kelvin Stott

Active Member
Joined
Oct 26, 2010
Messages
338
Hello,

I'm struggling to find a way to record the original value of a cell prior to change (rather than just the new value), so that I can use it in my change event procedure. Any ideas?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi Kelvin

You need to have stored it prior to the change in typically either:

1. Another cell
2. A workbook name
3. A Public or Globally scoped variable

So that then you can reference this to access the original value.

If you want help on how you might apply this, can you explain how you want to use this?
 
Upvote 0
Is it possible to use the change event itself to record the number *before* it is changed, similar to the before save event, or does the change event only follow the change?
 
Upvote 0
No - during the change event is too late I'm afraid. MS could have implemented the Change event to include a variable holding the old value (eg TargetOld perhaps) but they didn't (possibly down to memory considerations).
 
Upvote 0
Something like this might (crudely) be of some use.

Code:
Option Explicit

Public vPrevious As Variant

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, [A1]) Is Nothing Then

    Debug.Print vPrevious
    Debug.Print Target.Value
    
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

vPrevious = Target.Value

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,273
Messages
6,177,636
Members
452,787
Latest member
BeeTH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top