Worksheet_Change Event and undo

benntw

Board Regular
Joined
Feb 17, 2014
Messages
158
Does anyone know how to keep the undo along with worksheet change event. Here is my code that I am using.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range


'TRACKS DATE ENTRY WAS MARKED AS COMPLETE AND WHO UPDATED IT


If Target.Column = 21 Then
Application.EnableEvents = False
For Each rng In Target
If rng.Offset(0, 3).Value = "" Then
rng.Offset(0, 3) = Now()
End If
Next rng
Application.EnableEvents = True
End If


If Target.Column = 21 Then
Application.EnableEvents = False
For Each rng In Target
rng.Offset(0, 4) = Environ("Username")
Next rng
Application.EnableEvents = True
End If




'TRACKS DATE ENTRY WAS MARKED AS DELETED AND WHO UPDATED IT
If Target.Column = 22 Then
Application.EnableEvents = False
For Each rng In Target
If rng.Offset(0, 4).Value = "" Then
rng.Offset(0, 4) = Now()
End If
Next rng
Application.EnableEvents = True
End If


If Target.Column = 22 Then
Application.EnableEvents = False
For Each rng In Target
rng.Offset(0, 5) = Environ("Username")
Next rng
Application.EnableEvents = True
End If


End Sub


Thank you
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,343
It is not totally impossible but too advanced and not an easy task - there are some sources out there - basically you have to build your own undo history.
The only sure way to keep your undo history is not making changes to data in the workbook :)
 

Watch MrExcel Video

Forum statistics

Threads
1,109,518
Messages
5,529,311
Members
409,862
Latest member
lbisacca
Top