通过公式更改单元格时,VBA代码不会运行
工作表A具有从工作表B收集的数据范围。工作表A有一个宏,用于计算数据是否高于某个值,然后调用电子邮件模块向所选用户发送电子邮件。
当在工作表A上手动输入数据时,宏工作,但是当从工作表B中提取数据时,它不会触发。
我不确定我的VBA代码需要更改什么。
Private Sub Worksheet_Change(ByVal Target As Range) Call MailAlert(Target, "B5:M5", 4) Call MailAlert(Target, "B8:M8", 7) Call MailAlert(Target, "B11:M11", 6) Call MailAlert(Target, "B14:M14", 2) Call MailAlert(Target, "B17:M17", 4) Call MailAlert(Target, "B20:M20", 1) Call MailAlert(Target, "B23:M23", 3) Call MailAlert(Target, "B26:M26", 1) Call MailAlert(Target, "B29:M29", 5) Call MailAlert(Target, "B32:M32", 1) Call MailAlert(Target, "B35:M35", 7) Call MailAlert(Target, "B38:M38", 20) Call MailAlert(Target, "B41:M41", 0) End SubPrivate Sub MailAlert(ByVal Target As Range, ByVal Address As String, ByVal Value As Integer) If Target.Cells.Count > 1 Then Exit Sub If Not Application.Intersect(Range(Address), Target) Is Nothing Then If IsNumeric(Target.Value) And Target.Value > Value Then Call Mail_small_Text_Outlook End If Application.EnableEvents = True End IfEnd Sub
ibeautiful