【发布时间】:2014-04-28 23:49:10
【问题描述】:
如果行已更改,我需要在 Excel 工作簿中添加或更新时间戳。我正在进行数据导入,但我需要查看更新/添加的行以及日期。
到目前为止,我已经找到并调整了以下代码:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("A2:BL9999"), .Cells) Is Nothing Then
Application.EnableEvents = False
With .Cells(1, 65)
.NumberFormat = "yyyy.mm.dd"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub
问题是,时间戳总是相对于已进行更改的行 + 65 行添加,而不是在列 BM(索引 65)中。
您能告诉我,我应该使用或更改哪个功能?
【问题讨论】:
-
将
With .Cells(1, 65)更改为With Cells(1, 65) -
在这种情况下它根本没有更新
-
代码更新
BM1单元格 -
也许我做错了什么,但没有发生任何更改,我什至尝试复制新的 excel 文件并将范围和单元格设置为 10,如果进行了这些更改,则工作表中没有更新完全没有
-
按预期为我工作。单元格
BM1包含时间戳。顺便说一句,代码只有在A2:BL9999范围内更改 single 单元格时才有效