create user audit trail in microsoft excel 2010

此生再无相见时 提交于 2020-01-25 23:24:45

问题


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


来源:https://stackoverflow.com/questions/22948585/create-user-audit-trail-in-microsoft-excel-2010

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!