Excel VBA one macro to run multiple macros not working

Stuepef

Board Regular
Joined
Oct 23, 2017
Messages
128
Office Version
  1. 2021
Platform
  1. Windows
I want one macro to run several other macros, but when I write the code, I receive a compile error - sub or function not defined. What am I missing?

Code:
Sub Runallmacros()    
    Call LYRates
    Call TYRates
    Call DeleteSpaces
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
A few things come to mind.
1) Have you spelt the names correctly?
2) Are all those macros in the same workbook?
3) Are any of them Private Subs?
 
Upvote 0
Answers to your questions:
  1. The names of the macros are spelt accurately
  2. The macros are in the same workbook, but spread out across multiple worksheets (ie. Sheet1, Sheet2, Sheet3)
  3. None of the macros are private
 
Upvote 0
Do any of the macros have anything in the brackets like
Code:
Sub amacro(Rng as Range)
 
Upvote 0
No, all of the macros have everything outside the brackets (i.e. Sub LYRates () or Sub TYRates () )
 
Upvote 0
but spread out across multiple worksheets (ie. Sheet1, Sheet2, Sheet3)
Sheet module should only really be used for Event code & ActiveX controls.
Try moving the macros into regular modules.
 
Upvote 0
That was definitely the issue, moved the macros to a module and my code above works. Thank you for the help again! :)
 
Upvote 0
One more question, I transferred all the macros in a module, but one macro doesn't run. I checked the spelling and if I run that one macro separate, it runs just fine. Why would it not update when its with the other macros?
 
Upvote 0
Put the word Stop at the beginning of that macro & then run Runallmacros.
Does the VBE open up with the word Stop highlighted in yellow?
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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