Run Macro A if Cell A1 is equal to A...

rage300

New Member
Joined
Feb 25, 2005
Messages
12
I have a series of 4 macros that I need to run depending on which week of the month it is. I would like to automate this process by entering in the week number in Cell A1 and clicking a button that says "go". Can I set up a macro to run other macros depending on this value?

Thanks,

Jason
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Code:
sub checkmonth()
If Range("A1").Value = 1 then application.run "macro1name"
If Range("A1").Value = 2 then application.run "macro2name"
If Range("A1").Value = 3 then application.run "macro3name"
etc...
 
Upvote 0
Right click the sheet tab and select View Code. Copy and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Or Target.Address(False, False) <> "A1" Then Exit Sub
Select Case Target.Value
    Case 1:
        Call macroA
    Case 2:
        Call macroB
End Select
End Sub

Adjust to the values you expect in A1 and the macro names, then close the code window and test by changing the value in A1.
 
Upvote 0
You're a rockstar man. That was the easiest thing I did all day. And thanks for such a quick response.


Have a great day.
 
Upvote 0

Forum statistics

Threads
1,218,626
Messages
6,143,582
Members
450,494
Latest member
GolfNut39

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