怎样用最简洁的代码来判断表单中的数据是否更改过!
1个回答
展开全部
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error Resume Next
If Target.Column = 1 And Target.Row >= 2 Then
If IsNumeric(Target.Value) = True And Target.Value > 0 Then
'设定值必须为数值,且大于0
Target.Offset(0, 1) = Now
Target.Offset(0, 1).NumberFormatLocal = "yyyy-m-d h:mm;@"
Else
Target.Offset(0, 1) = ""
End If
End If
Application.EnableEvents = True
End Sub
Application.EnableEvents = False
On Error Resume Next
If Target.Column = 1 And Target.Row >= 2 Then
If IsNumeric(Target.Value) = True And Target.Value > 0 Then
'设定值必须为数值,且大于0
Target.Offset(0, 1) = Now
Target.Offset(0, 1).NumberFormatLocal = "yyyy-m-d h:mm;@"
Else
Target.Offset(0, 1) = ""
End If
End If
Application.EnableEvents = True
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询