If cell meets condition then run macro

Swoootie

Board Regular
Joined
Jun 28, 2012
Messages
66
Hi all,

I have an IF statement where I want code in a different macro executed when a cell is populated with a specific value. My code thus far is below:

Sub RUNOPT()
Sheets("Main Page").Select
If Sheets("Main PAGE").Range("L15") = "A" Then Call RUNA
If Sheets("Main PAGE").Range("L15") = "B" Then Call RUNB
If Sheets("Main PAGE").Range("L15") = "C" Then Call RUNC
If Sheets("Main PAGE").Range("L15") = "D" Then Call RUND
End Sub

Is it possible to add such conditions to an IF statement. I'm not entirely sure what is going on.

Any help would be greatly appreciated.

Thanks
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Maybe like this

Code:
Sub RUNOPT()
Sheets("Main Page").Select
Select Case Range("L15").Value
    Case "A": Call RUNA
    Case "B": Call RUNB
    Case "C": Call RUNC
    Case "D": Call RUND
End Select
End Sub
 
Upvote 0
Hi all,

I have an IF statement where I want code in a different macro executed when a cell is populated with a specific value. My code thus far is below:

Sub RUNOPT()
Sheets("Main Page").Select
If Sheets("Main PAGE").Range("L15") = "A" Then Call RUNA
If Sheets("Main PAGE").Range("L15") = "B" Then Call RUNB
If Sheets("Main PAGE").Range("L15") = "C" Then Call RUNC
If Sheets("Main PAGE").Range("L15") = "D" Then Call RUND
End Sub

Is it possible to add such conditions to an IF statement. I'm not entirely sure what is going on.

Any help would be greatly appreciated.

Thanks

Yes. Have you tried it?
 
Upvote 0
Apologies. I was referencing a module not the sub procedure. Now corrected.

Thanks for all your help. :)
 
Upvote 0
Thanks for the feedback.
Regards, JLG
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,038
Members
448,940
Latest member
mdusw

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