简体   繁体   中英

Combining two worksheet change events excel vba

I have tried to figure out how to combine the Worksheet_Change events below to run in the same worksheet. They work flawless in different sheets, but not together.

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Range("D4").Interior.Color = RGB(Range("D6"), Range("E6"), Range("F6"))
    On Error GoTo 0
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B4")) Is Nothing Then
        Exit Sub
    Else
        Macro4
    End If
End Sub

Any help our guidance would be highly appreciated.

You don't need to do much...

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Range("D4").Interior.Color = RGB(Range("D6"), Range("E6"), Range("F6"))
    If Intersect(Target, Range("B4")) Is Nothing Then Exit Sub
    Macro4
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM