[英]last update date of a range stored in the single cell excel
因此,我有一個excel工作表,其中有一個范圍A2:A3,我想知道是否可以將特定范圍的最后一次更新時間存儲到B1中的某個單元格中嗎? 我在VBA世界中真的很了解。 會非常感謝您的幫助:)
code
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng1 As Range
Set rng1 = Intersect([a2:a3], Target)
If rng1 Is Nothing Then Exit Sub
Application.EnableEvents = False
[b1] = Format(Now(), "dd-mm-yyyy hh:mm:ss")
Application.EnableEvents = True
End Sub
'已編寫此宏,以更新每個A2:D43415的上次修改日期/時間'上次修改日期應用於列F。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rInt As Range
Dim rCell As Range
Dim tCell As Range
Dim tColInt As Integer
tColInt = 6 'Column Index, Example: A=1, B=2, ...... ,Z=26
Set rInt = Intersect(Target, Range("A2:D43415")) 'Change cell range
If Not rInt Is Nothing Then
For Each rCell In rInt
Set tCell = Cells(rCell.Cells.Row, tColInt)
If IsEmpty(tCell) Or Not IsEmpty(tCell) Then
tCell = Now
tCell.NumberFormat = "dd/mm/yyyy h:mm:ss AM/PM" 'Custom Format
End If
Next
End If
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.