Hi all
I have the below code that displays the changes made to cell values prior to saving the workbook. What I'm trying to figure out how to do, is place the value of the cell prior to the change into a variable and display the old value as well as the new value when the file is saved. The below obviously doesn't work as it simply uses the activecell, not the one that was changed... Thanks for the help.
I have the below code that displays the changes made to cell values prior to saving the workbook. What I'm trying to figure out how to do, is place the value of the cell prior to the change into a variable and display the old value as well as the new value when the file is saved. The below obviously doesn't work as it simply uses the activecell, not the one that was changed... Thanks for the help.
Code:
Private sCellsChanged As String
Private sCellOriginalValue As String
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If sCellsChanged <> "" Then
MsgBox sCellsChanged
sCellsChanged = ""
sCellOriginalValue = ""
End If
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
sCellOriginalValue = ActiveCell.Value
sCellsChanged = sCellsChanged & Sh.Name & " " & Target.Address & " Old Value " & sCellOriginalValue & " New Value: " & Target.Value & vbCrLf
End Sub