我正在使用VBA檢查單元格的值,並調用電子郵件模塊發送電子郵件,如果單元格的值超過一個值。合併兩個私人小組Worksheet_Change
我想檢查多個單元,但明白在VBA中不能有兩個Private Sub Worksheet_Change。檢查多個單元格的最佳方法是什麼?
這是我使用的代碼;
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value > 10 Then
Call Mail_small_Text_Outlook
End If
End If
End Sub
這裏是另一個可能的話,我想合併到一個子
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("B1"), Target) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value > 20 Then
Call Mail_small_Text_Outlook
End If
End If
End Sub
爲什麼不把'If Not Application.Intersect ...'塊同時放到同一個Sub中? –