Can we have multiple Sub and End Sub in a single VBA Code?

An Quala

Board Regular
Joined
Mar 21, 2022
Messages
146
Office Version
  1. 2021
Platform
  1. Windows
Hello, a very basic question, Can we have multiple Sub and End Sub in a single VBA Code? Is yes, then when should we use multiple sub end sub because I am combining multiple codes written by different people I think it's a good idea to have sub end sub with each one,

Thank you.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
No you cant.
As I said in a previous post don't bother combining them into one macro, just call them from another.
 
Upvote 0
Solution
No you cant.
As I said in a previous post don't bother combining them into one macro, just call them from another.
Hi, I need to have all in a single code, I will try.
 
Upvote 0
Do you mean you want to put multiple subroutines (Sub...End Sub blocks) in a single code module? If that is so then yes you can. However, if you are combining code from multiple places you might consider placing each code set in separate code modules to help in organizing them.

If the code you seeking to combine was not written as a Sub...EndSub block originally then you may have other concerns to worry about. It sounds to me like you need more help with code organization.
 
Upvote 0
Judging ny this & other threads, the OP is trying to combine multiple subs into a single sub, not into a single module.
 
Upvote 0
I want to have one single trigger to run all the codes, but as you suggest to save each of them separately and call them in a single SUB would be too messy I think.
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,945
Members
449,198
Latest member
MhammadishaqKhan

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