-1

I have an Excelsheet with 2 columns. The second column must only contain values which are also in the first column. If a value in the first column changes I have to replace all its occurrences in the second column. There is a Worksheet_Change event which is called if a worksheet changes but unfortunately I can't find a way to get the old value of a changed cell.

Is it possible to find out the old value of a cell?

mpav
  • 13
  • 4
  • What's your code doing? – Mathieu Guindon Nov 03 '17 at 20:39
  • Thanks for the answer. I've found [get the old value in a worksheet change target](https://stackoverflow.com/questions/4668410/how-do-i-get-the-old-value-of-a-changed-cell-in-excel-vba). The selection_change event is mentioned there too. – mpav Nov 04 '17 at 10:01
  • Possible duplicate: https://stackoverflow.com/questions/4668410/how-do-i-get-the-old-value-of-a-changed-cell-in-excel-vba – Jerry Jeremiah Mar 21 '23 at 22:05

1 Answers1

3

Edit: I read your question wrong, here's to get your old value before selection change

Dim oldValue As Variant
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    oldValue = Target.Value
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
    'Do whatever you need to do.
End Sub
pokemon_Man
  • 902
  • 1
  • 9
  • 25
  • 3
    Now we're talking! OP might need to perhaps verify the `Target` column in `SelectionChange`, but that's a good start; capture the old value *before* it's modified. Given how much effort OP put in their question, I think that's more than good enough to earn a vote. – Mathieu Guindon Nov 03 '17 at 20:43