我想过滤工作表以仅显示带有“跟踪修订”功能标记为待审阅的单元格的行。有人知道这是否可行/如何实现吗?
答案1
下面编写的代码将突出显示活动工作表中的每个更改和新条目,并将创建一个日志工作表,其中包含工作表名称、单元格地址和输入的数据。
它就像一张审计表。
突出显示新条目的工作原理Mark Track Changes
和将数据移动到日志文件的工作原理一样Filter those entries
您还可以修改此代码以满足进一步的需求。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet, ws2 As Worksheet
Dim i As Boolean
Application.ScreenUpdating = False
i = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name = "Change Log" Then
i = True
Exit For
End If
Next ws
If Not i Then
Set ws2 = ThisWorkbook.Worksheets.Add
ws2.Name = "Change Log"
ws2.Range("A1") = "Sheet"
ws2.Range("B1") = "Range"
ws2.Range("C1") = "New Data"
Else
Set ws2 = Sheets("Change Log")
End If
ws2.Range("A1").Offset(ws2.UsedRange.Rows.Count, 0) = Target.Worksheet.Name
ws2.Range("B1").Offset(ws2.UsedRange.Rows.Count - 1, 0) = Target.Address
ws2.Range("C1").Offset(ws2.UsedRange.Rows.Count - 1, 0) = Target.Cells.Value
Target.Font.Color = 255
Application.ScreenUpdating = True
End Sub