[英]Vba Worksheet_Change event does not trigger when copy and paste data into column but works with a manual click into cell
[英]Excel VBA Copy paste into cell doesnt trigger worksheet_change
每当有人更改单元格B8时,我都试图将日期格式化为固定格式,手动输入数据似乎会触发Macro-checkdateformat,但是将复制粘贴到单元格时不会触发。
下面是我的代码。
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$8" Then
Call Checkdateformat
End If
End Sub
目标可以超过一个单元。 您只需要检查B8是否为其中之一即可。 若要查看某个单元格是否在较大的一组单元格(或仅另一个单元格)中,请使用“相交”。
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If not intersect(target, range("B8")) is nothing then
'B8 is part of Target
on error goto safe_exit
application.enableevents = false
Call Checkdateformat
End If
safe_exit:
application.enableevents = true
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.