Question : What was in the cell?

Hi Experts,

I have values in various cells. I then manually change one of the values. How can I with VBA retrieve the original value so that I can make use of it? Clearly Excel has a roll-back procedure so it must store that information somewhere - the question is where and how can it be accessed?

Patrick

Answer : What was in the cell?

Hello patrickab,

Try the following which uses the undo and then resets the data:

Regards,

chris_bottomley
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strOld As String
Dim strNew As String

    Application.EnableEvents = False
    strNew = Target
    Application.Undo
    strOld = Target
    Target = strNew
    MsgBox "Cell Data was: " & strOld & vbCrLf & "New data is: " & strNew
    Application.EnableEvents = True

End Sub
Random Solutions  
 
programming4us programming4us