因此,我與我的團隊共享了這個電子表格,並且我正在尋找一種方法,可以在每次工作表中發生更改時將今天的日期放入單元格中。我找到了這個編碼,它正在工作,但是,我不想彈出訊息,我想要今天()插入儲存格 D2 (我不需要時間,只需要日期)。任何幫助將非常感激。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("A1:W160")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
' Display a message when one of the designated cells has been
' changed.
' Place your code here.
MsgBox "Cell " & Target.Address & " has changed."
End If
End Sub