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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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