Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
i = Target.Row
If i > 3 And Target.Column = 11 Then
Columns("D:D").NumberFormatLocal = "yyyy/m/d h:mm;@"
If Cells(i, 3) = Cells(i - 1, 3) Then
Cells(i, 4) = Cells(i - 1, 4)
Else
Cells(i, 4) = Now()
End If
End If
End Sub
这个是工作表事件过程,一定要放在工作表对应的代码中窗口中。