Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 1 And Target.Value <> "" Then
Target.Offset(0, 1) = Format(Now, "yyyy-mm-dd hh:mm:ss")
End If
If Target.Column = 3 And Target.Value <> "" Then
If [A:A].Find(Target, lookat:=xlWhole) Is Nothing Then Exit Sub
If Cells([A:A].Find(Target, lookat:=xlWhole).Row, 4) = "" then Cells([A:A].Find(Target, lookat:=xlWhole).Row, 4) = Format(Now, "yyyy-mm-dd hh:mm:ss")
End If
End Sub
代码可以实现在A列输入内容,在B列的同一行自动输入日期;另外在C列输入内容,可以在A列查找与之相同的数据的行,然后在D列的同一行自动输入日期。
但这个代码如何加以修改,能够实现:
当D列的那行不为空时,才自动输入日期,且要找到A列所有与C列输入内容相同的行,并在D列自动输入日期。上面的代码不能实现,当C列8行输入2时,在D列7行自动输入日期——如何修改代码实现这一点?