![](/img/trans.png)
[英]Automatically update date and time data in column A when updating data in the range from B to Z
[英]Update Date automatically when I log data
我一直在填寫Excel工作表記錄項目信息。 我想知道在更新同一張紙的相鄰行中的單元格時,如何用當前日期填充一個單元格。 當前在相鄰的單元格中有信息,但我希望它保留以前更新它的日期。 只有當我更新信息時,我才希望更改它
我已經在Google上搜索了邏輯運算符信息,但似乎找不到直接答案。 如果有VB宏,我可以接受任何解決方案。 我也在Excel中也找到了關於TODAY()函數的信息,但是我不知道如何將其應用於我的特定問題。 對VB宏或信息的任何引用都將有所幫助。 謝謝。
嘗試使用Alt-F11來啟動編輯器,右鍵單擊“ Sheet1”(或您的工作表名稱),然后選擇添加代碼,並粘貼如下內容:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("B2:B10")
If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
Cells(Target.Row, Target.Column - 1) = Now()
End If
End Sub
如果在B2到B10中鍵入內容,則相鄰列將使用當前日期更新。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.