Private Sub - run a different macro

Rowanhf12

New Member
Joined
Jan 22, 2016
Messages
27
I have the following code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)If Not Application.Intersect(Range("BA1:BA3"), Range(Target.Address)) Is Nothing Then
Call Part1V1
End If
End Sub


Sub QPart1V1()
    Dim CellRangeP1V1 As String
    CellRangeP1V1 = Range("AX6").Value
    Range("AU4").Select
    Selection.Copy
    Range("BA" & CellRangeP1V1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
End Sub

This basically copies a value into the Range BA1:BA3, that then activates another Macro

At the moment, a value only gets copied into cell BA1 which activates macro:Part1V1
How do I make it so that when a value gets copied into cell BA2, it activates another macro?

Any help would be appreciated

Thank you
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If you want it to call different macros depending on whether the data is being pasted in BA1 or BA2, then you need to add a second check, and narrow the search to only check for that one cell instead of BA1:BA3.

So, your Worksheet_Change procedure would look something like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)


'   Call macro Part1V1 when data pasted in cell BA1
    If Not Application.Intersect(Range("BA1"), Target) Is Nothing Then
        Call Part1V1
    End If
    
'   Call a different macro when data pasted in cell BA2
    If Not Application.Intersect(Range("BA2"), Target) Is Nothing Then
        Call SomeOtherMacro
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,212,932
Messages
6,110,748
Members
448,295
Latest member
Uzair Tahir Khan

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