How to call two Macros with the same cell change

PVA0724

New Member
Joined
Apr 21, 2012
Messages
48
Hi Members

I've been trying to figure out a way to call two macros based on a condition given by the same cell. So for example I have

Cell C9 = Bloqueo (for Spanish)

and through Macros I'm changing that to English so it will be like

Cell C9 = Block

so when C9 is Bloqueo I need the following code

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

 If Target.Address = "$C$9" Then Call JBACond1
End Sub

But when C9 is Block I need the following code

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

 If Target.Address = "$C$9" Then Call JBACond2
End Sub

So it's possible to trigger different macros based on how the statement of the same cell change.

Thanks in advance for your assistance.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
See if this does it for you:

<font face=Calibri><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br>    <SPAN style="color:#007F00">'   Code goes in the Worksheet specific module</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> rng <SPAN style="color:#00007F">As</SPAN> Range<br>        <SPAN style="color:#007F00">'   Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")</SPAN><br>        <SPAN style="color:#00007F">Set</SPAN> rng = Target.Parent.Range("C9")<br>             <SPAN style="color:#007F00">'   Only look at single cell changes</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> Target.Count > 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>            <SPAN style="color:#007F00">'   Only look at that range</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> Intersect(Target, rng) <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>            <SPAN style="color:#007F00">'   Action if Condition(s) are met (do your thing here...)</SPAN><br>            <SPAN style="color:#00007F">Select</SPAN> <SPAN style="color:#00007F">Case</SPAN> Target.Value<br>                <SPAN style="color:#00007F">Case</SPAN> "Bloqueo"<br>                    <SPAN style="color:#00007F">Call</SPAN> JBACond1<br>                <SPAN style="color:#00007F">Case</SPAN> "Block"<br>                    <SPAN style="color:#00007F">Call</SPAN> JBACond1<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Select</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$C$9" Then Exit Sub
Select Case Target.Value
    Case "Block":  Call JBACond2
    Case "Bloqueo": Call JBACond1
End Select
End Sub
 
Upvote 0
Something like this should work:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = "$C$9" Then 
    If Target.value = "Bloqueo" then 
      Call JBACond1
    ElseIf target.value = "Block" then
      Call JBACond2
    End If
  End if
End Sub


Tim
End Sub
 
Upvote 0
Hi All

First thank you for the quick turnaround.

Also now I'm looking for the solution proposed, I noted that I missed to explain something else.

In Cell C9 that trigger the case statement it's also another options so for example

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$C$9" Then Exit Sub
    Select Case Target.Value    
      Case "Block" or Case "Unblock" or Case "Modification":  Call JBACond2    
      Case "Bloqueo" or Case "Desbloqueo" or Case "Modificación: Call JBACond1
    End Select
End Sub

So would it be possible to have the or statement to separate different cases that will trigger the same macro, where cell C9 has a Validation list with those values.

Again, thank you so much.
 
Last edited by a moderator:
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$C$9" Then
        Select Case Target.Value
            Case "Block", "Unblock", "Modification"
                Call JBACond2
            Case "Bloqueo", "Desbloqueo", "Modificación"
                Call JBACond1
        End Select
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,613
Messages
6,120,515
Members
448,968
Latest member
Ajax40

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