Excel 审核跟踪的日志时间和更改表

Excel 审核跟踪的日志时间和更改表,excel,vba,Excel,Vba,我正在用Excel进行审计跟踪。我想记录进行更改的时间和工作表 Dim PreviousValue Private Sub Worksheet_Change(ByVal Target As Range) If Target.Value <> PreviousValue Then Sheets("log").Cells(65000, 1).End(xlUp).Offset(1, 0).Value = _ Application.UserName & "

我正在用Excel进行审计跟踪。我想记录进行更改的时间和工作表

Dim PreviousValue

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value <> PreviousValue Then
    Sheets("log").Cells(65000, 1).End(xlUp).Offset(1, 0).Value = _
        Application.UserName & " changed cell " & Target.Address _
        & " from " & PreviousValue & " to " & Target.Value
    End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    PreviousValue = Target.Value
End Sub
试试这个

Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Value <> PreviousValue Then
    Sheets("log").Cells(65000, 1).End(xlUp).Offset(1, 0).Value = _
        Application.UserName & " changed cell " & Target.Address _
        & " from " & PreviousValue & " to " & Target.Value & " from sheet " & ActiveSheet.Name & " at " & Time
    End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    PreviousValue = Target.Value
End Sub

你的代码正在运行。唯一的问题是,您应该将其粘贴到要审核的工作表中。所以,如果您有Sheet1 sheet,只需右键单击选项卡>显示代码上的按钮。然后粘贴代码并。。。完成!