Public TrackChanges As Boolean Sub ToggleCellHistory() TrackChanges = Not TrackChanges If TrackChanges Then MsgBox "单元格历史记录功能已开启。" Else MsgBox "单元格历史记录功能已关闭。" End If End Sub Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) If TrackChanges Then Dim cell As Range For Each cell In Target If cell.Comment Is Nothing Then cell.AddComment End If cell.Comment.Text Text:=Format(Now, "yyyy-mm-dd hh:mm:ss") & ": " & cell.Value & Chr(10) & cell.Comment.Text Next cell End If End Sub