Excel:過濾需要接受的最近更改

Excel:過濾需要接受的最近更改

我想過濾工作表以僅顯示帶有標記為供“跟踪更改”功能審閱的單元格的行。有誰知道這是否/如何可能?

答案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

相關內容