I am trying to capture the value of a cell before a change even. The attached Macro will report the value before the change but does not store it so that I can use it in another module. What I am trying to do is capture the value before the change and then look that value up in another worksheet (in the same workbook) so I can make the same change in the second workbook.
The values will always be in Column B and will always be string characters.
The code I am using for the change event is as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldValue As String
If Flag Then Exit Sub
If Intersect(Target, Range("B7:B132")) Is Nothing Then Exit Sub
With Application
On Error GoTo ErrHandler
.EnableEvents = False
.Undo
OldValue = Target.Cells(1).Value
.Undo
.EnableEvents = True
End With
MsgBox "Value was " & OldValue
ErrHandler:
Application.EnableEvents = True
If Err.Number <> 0 Then
MsgBox "Error: " & Err.Number & vbNewLine & Err.Description
End If
End Sub
Can you give me some direction on how to capture the OldValue so as to use it as a variable in another module?
Thanks...John
Bookmarks