ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling macro from a different moldule (https://www.excelbanter.com/excel-programming/354813-calling-macro-different-moldule.html)

Vanna

Calling macro from a different moldule
 
I created 4 different macros in 4 different modules. I like to create one
main macro which calls these 4 modules. I tried to enter the macro names one
after another in the new module and it's giving me an error. Do I need to
declare the other 4 macros to public?

mudraker[_339_]

Calling macro from a different moldule
 

If the macros are in a normal module sheet you do not need to declare
them as public

try

Sub MainMacro ()
Call Macro1
Call Macro2
Call Macro3
Call Macro4
MyInfo = Function5Result
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=518093


Vanna

Calling macro from a different moldule
 
Thanks to your reply. I tied your suggestion but still get an error.
I created the macros in modules. Instead of calling them module1,
module2...I renamed the macros. In my main macro, I enter the follwing codes:

Sub main()
Call DelFre_Keystone
Call DelFre_Symmetry
Call DelFre_Folio
Call RecFre_Keystone
Call RecFre_Symmetry
Call RecFre_Foli
end sub()

I get an error "Compile Error" expected variables or procedures, not module


"mudraker" wrote:


If the macros are in a normal module sheet you do not need to declare
them as public

try

Sub MainMacro ()
Call Macro1
Call Macro2
Call Macro3
Call Macro4
MyInfo = Function5Result
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=518093



Vanna

Calling macro from a different moldule
 
Sorry, my mistake. I call the module name instead of the name of the sub
procedure.

"Vanna" wrote:

Thanks to your reply. I tied your suggestion but still get an error.
I created the macros in modules. Instead of calling them module1,
module2...I renamed the macros. In my main macro, I enter the follwing codes:

Sub main()
Call DelFre_Keystone
Call DelFre_Symmetry
Call DelFre_Folio
Call RecFre_Keystone
Call RecFre_Symmetry
Call RecFre_Foli
end sub()

I get an error "Compile Error" expected variables or procedures, not module


"mudraker" wrote:


If the macros are in a normal module sheet you do not need to declare
them as public

try

Sub MainMacro ()
Call Macro1
Call Macro2
Call Macro3
Call Macro4
MyInfo = Function5Result
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=518093




All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com