我有一个代码,如果在F列的同一行的单元格中进行了任何更改,则在D列的单元格中更新日期:
pw-40
现在我需要调整此代码,以便在D列中的单元格中更新日期,如果在F到K列的同一行中的单元格中进行了任何更改。
我对VBA知识很少,并且对于调整代码的任何帮助表示感谢。
答案 0 :(得分:0)
这似乎有效:
Private Sub Worksheet_Change(ByVal Target As Range)
' Code to put the date of the latest update following a change in the corresponding cell in column F
Dim WorkRng As Range, roww As Long
Dim rng As Range
Set WorkRng = Intersect(Range("F:K"), Target)
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each rng In WorkRng
roww = rng.Row
If Not rng.Value = "" Then
Cells(roww, "D").Value = Now
Cells(roww, "D").NumberFormat = "dd/mm/yyyy"
Else
Cells(roww, "D").ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub
我们只是不使用OFFSET()