Worksheet with Multiple Worksheet Changes

roccoau

New Member
Joined
Dec 25, 2016
Messages
10
Hi
I have a worksheet which I would like to add 3 different change requests as per below
I get below message so I gather this may not be possible
Does anyone have any tips on how to get around this.
I am only new to Excel code so help much appreciated

Thanks
Rocco
1616105365458.png


CODE
----------------------------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim v As Variant

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("C16:C29")) Is Nothing Then Exit Sub 'specific range

'Turn off events to keep out of loops
Application.EnableEvents = False

v = Application.Match(Target.Value, Worksheets("Lists").Range("B:B"), False)

If Not IsError(v) Then
Target.Value = Worksheets("Lists").Range("A:A").Cells(v).Value
End If

'Turn events back on to get ready for the next change
Application.EnableEvents = True
End Sub
----------------------------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim v As Variant

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("G16:G29")) Is Nothing Then Exit Sub 'specific range

'Turn off events to keep out of loops
Application.EnableEvents = False

v = Application.Match(Target.Value, Worksheets("Lists").Range("F:F"), False)

If Not IsError(v) Then
Target.Value = Worksheets("Lists").Range("E:E").Cells(v).Value
End If

'Turn events back on to get ready for the next change
Application.EnableEvents = True
End Sub
----------------------------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim v As Variant

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("H16:H29")) Is Nothing Then Exit Sub 'specific range

'Turn off events to keep out of loops
Application.EnableEvents = False

v = Application.Match(Target.Value, Worksheets("Lists").Range("I:I"), False)

If Not IsError(v) Then
Target.Value = Worksheets("Lists").Range("H:H").Cells(v).Value
End If

'Turn events back on to get ready for the next change
Application.EnableEvents = True
End Sub
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,388
Office Version
  1. 365
Platform
  1. Windows
You can only have one per worksheet. This should do it:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim v As Variant

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("C16:C29,G16:G29,H16:H29")) Is Nothing Then Exit Sub 'specific range

'Turn off events to keep out of loops
Application.EnableEvents = False

Select Case Target.Column
    Case 3
        v = Application.Match(Target.Value, Worksheets("Lists").Range("B:B"), False)
        If Not IsError(v) Then Target.Value = Worksheets("Lists").Range("A:A").Cells(v).Value
    Case 7
        v = Application.Match(Target.Value, Worksheets("Lists").Range("F:F"), False)
        If Not IsError(v) Then Target.Value = Worksheets("Lists").Range("E:E").Cells(v).Value
    Case 8
        v = Application.Match(Target.Value, Worksheets("Lists").Range("I:I"), False)
        If Not IsError(v) Then Target.Value = Worksheets("Lists").Range("H:H").Cells(v).Value
End Select

'Turn events back on to get ready for the next change
Application.EnableEvents = True

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,129,752
Messages
5,638,162
Members
417,011
Latest member
Amaden95

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
Top