Private Sub Worksheet_Change(ByVal Target As Range)

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,786
Office Version
  1. 365
Platform
  1. Windows
I have been told that I cant have 2 Private Sub Worksheet_Change(ByVal Target As Range) in one worksheet. What can I do as I have 2 codes that have this.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Put them both in the same event and branch to decide which to code to run

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells = 1 Then
        If Target.Column = 1 Then
            Rem code for column A
        ElseIf Target.Column = 3 Then
            Rem code for column B
        End If
    End If
End Sub
Your situation is probably not testing for columns A vs. C, but the principle is the same.
 
Upvote 0
Sorry I dont understand as both need to run!
 
Upvote 0
Then put one after the other.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Rem one routine
    Rem the other 
End Sub

Perhaps if you posted the two routines, it would be easier to see what you want them to do and how to combine them.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top