Utilizing Same Macros for Different Processes

madhuchelliah

Board Regular
Joined
Nov 22, 2017
Messages
226
Office Version
  1. 2019
Platform
  1. Windows
Hello guys, I have totally 30 macros for processes. I have 2 processes 1st consists of 20 macros and 2nd consists of all 30 macros. In my 20th macro i have given a message box as completed. For my 2nd process i want to continuously run the macro after 20th to 21st without message box. Now i am using by duplicating macros with different names. It is very difficult to maintain. Is there any method to utilize same macros for both the processes?. Thank you.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
can't imagine what your macros look like, could there be a way of looping through them ?. The short answer yes it can be done, by declaring a variable in one part of the code and changing what is passed
 
Upvote 0
Hello Mole, Thanks for the response. I have 30 individual macros. Using call function i am running the macros. Could you pls give any example to do that. My 20th macro contains just the cell alignment and message box. After this alignment i want to trigger my 21st macro.
 
Upvote 0
OK, basic outline


Declare a Global Variable i.e, X

sub main
X = 3
Call Loop
X = 6
Call Loop
X = 7
Call Loop
Exit Sub

Sub Loop
use X in code
Exit Sub

as you run down main each part is called as necessary, the value of X is changed and Loop is reused

If you have a run of numbers you might want to consider a second Loop for some differences you can't bring into the main macro, you might use FOR NEXT for X = 1 to 250 NEXT x
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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