Excel VBA复制粘贴到单元格不会触发worksheet_change

我想格式化一个date到一个固定的格式每次有人改变单元格B8,手动input数据似乎触发macroscheckdateformat但复制粘贴到单元格不触发。

以下是我的代码。

Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$B$8" Then Call Checkdateformat End If End Sub 

目标可能不止一个单元格。 你只需要检查B8是否是其中之一。 若要查看一个单元格是否在一个较大的单元格组中(或者只是一个其他单元格),请使用Intersect。

 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