I need to create a basic user audit trail in Excel 2010 tracking changes to certain cells by different users not signing into a PC (shared PC)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The following macro monitors changes to cells A2 thru A20
If a user changes any of these cells, the username and date are recorded in the cell's comment
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("A2:A20")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Dim s As String
s = Now & vbCrLf & Environ("UserName")
With Target
.ClearComments
.AddComment s
End With
Application.EnableEvents = True
End Sub