我正在尝试创建一个代码来更新列中的日期值" X"如果A:AE内的任何细胞都有变化吗?更新功能必须仅适用于同一行。例如,我对A1进行了更改,并更新了X1。非常感谢!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R1 As Range
Dim R2 As Range
Dim InRange As Boolean
Set R1 = Range(Target.Address)
Set R2 = Range("A:AE")
Set InterSectRange = Application.Intersect(R1, R2)
InRange = Not InterSectRange Is Nothing
Set InterSectRange = Nothing
If InRange = True Then
R1.**Offset(0, 1)**.Value = Now()
End If
Set R1 = Nothing
Set R2 = Nothing
End Sub
答案 0 :(得分:0)
您可以使用Target.Row来确定行,因此您可以使用:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 31 And Target.Column <> 24 Then
Cells(Target.Row, 24) = Now()
End If
End Sub