Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tie 2 or More Modules Together (vba)
Can anyone tell me if there is a formula or coding that would tell one module to reference another? I am trying to get it where when it runs through my code and reaches a true statement then it would then go onto the next module and do the same. I am working with several sections in an excel worksheet so I am trying to keep my coding separate and clean. If anyone could help I would appreciate it. Thank You, Chris -- zero635 ------------------------------------------------------------------------ zero635's Profile: http://www.excelforum.com/member.php...o&userid=24802 View this thread: http://www.excelforum.com/showthread...hreadid=387568 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tie 2 or More Modules Together (vba)
From a macro in a standard module you should be able to call another macro
in a standard module. Run "Macro1_name" it gets a little trickier if the macro to run is in a sheet module or in another workbook. -- steveB Remove "AYN" from email to respond "zero635" wrote in message ... Can anyone tell me if there is a formula or coding that would tell one module to reference another? I am trying to get it where when it runs through my code and reaches a true statement then it would then go onto the next module and do the same. I am working with several sections in an excel worksheet so I am trying to keep my coding separate and clean. If anyone could help I would appreciate it. Thank You, Chris -- zero635 ------------------------------------------------------------------------ zero635's Profile: http://www.excelforum.com/member.php...o&userid=24802 View this thread: http://www.excelforum.com/showthread...hreadid=387568 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tie 2 or More Modules Together (vba)
If you have
Module1 Sub1 Sub2 Module2 Sub3 Sub4 you should be able to call each sub(or function) from within the other modules *unless* you prefaced the name with Private or the procedure you're trying to call is in a Userform/Sheet/ThisWorkbook module. e.g. Sub IDoWork() 'can be called from within any other procedure End Sub Private Sub IDontWork() 'can only be called from a procedure from within the same module End Sub zero635 wrote: Can anyone tell me if there is a formula or coding that would tell one module to reference another? I am trying to get it where when it runs through my code and reaches a true statement then it would then go onto the next module and do the same. I am working with several sections in an excel worksheet so I am trying to keep my coding separate and clean. If anyone could help I would appreciate it. Thank You, Chris |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tie 2 or More Modules Together (vba)
Hi Gareth,
you should be able to call each sub(or function) from within the other modules *unless* you prefaced the name with Private or the procedure you're trying to call is in a Userform/Sheet/ThisWorkbook module. Provided that the worksheet. ThisWorkbook and Userform subs are declared Public, they can be called. like any other sub, from a standard module. For example, I put salutational Msgboxes in the Worksheet_Calculate event of sheet(1), the ThisWorkbook Workbook_Open sub and Uerform1's click event. Then running the following sub from a standard module. I duly received three greetings: Sub Tester04() Sheets(1).Worksheet_Calculate ThisWorkbook.workbook_open UserForm1.UserForm_Click End Sub --- Regards, Norman "Gareth" wrote in message ... If you have Module1 Sub1 Sub2 Module2 Sub3 Sub4 you should be able to call each sub(or function) from within the other modules *unless* you prefaced the name with Private or the procedure you're trying to call is in a Userform/Sheet/ThisWorkbook module. e.g. Sub IDoWork() 'can be called from within any other procedure End Sub Private Sub IDontWork() 'can only be called from a procedure from within the same module End Sub zero635 wrote: Can anyone tell me if there is a formula or coding that would tell one module to reference another? I am trying to get it where when it runs through my code and reaches a true statement then it would then go onto the next module and do the same. I am working with several sections in an excel worksheet so I am trying to keep my coding separate and clean. If anyone could help I would appreciate it. Thank You, Chris |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tie 2 or More Modules Together (vba)
Hi Norman,
I already UserForms in this manner extensively - I just didn't want to overcomplicate things in my previous post so I omitted it (honest - it wasn't laziness!). I didn't know you could do the same for thisworkbook and sheet modules however so thanks a lot for that. Very useful. I noticed while trying it out by the way, that you don't have to specifically declare the sub public. Presumably it's assumed public if neither private nor public is declared - a bit like variables I s'pose. I guess I should always be declaring one or the other rather than leaving it to default. Thanks - cya, G Norman Jones wrote: Hi Gareth, you should be able to call each sub(or function) from within the other modules *unless* you prefaced the name with Private or the procedure you're trying to call is in a Userform/Sheet/ThisWorkbook module. Provided that the worksheet. ThisWorkbook and Userform subs are declared Public, they can be called. like any other sub, from a standard module. For example, I put salutational Msgboxes in the Worksheet_Calculate event of sheet(1), the ThisWorkbook Workbook_Open sub and Uerform1's click event. Then running the following sub from a standard module. I duly received three greetings: Sub Tester04() Sheets(1).Worksheet_Calculate ThisWorkbook.workbook_open UserForm1.UserForm_Click End Sub --- Regards, Norman "Gareth" wrote in message ... If you have Module1 Sub1 Sub2 Module2 Sub3 Sub4 you should be able to call each sub(or function) from within the other modules *unless* you prefaced the name with Private or the procedure you're trying to call is in a Userform/Sheet/ThisWorkbook module. e.g. Sub IDoWork() 'can be called from within any other procedure End Sub Private Sub IDontWork() 'can only be called from a procedure from within the same module End Sub zero635 wrote: Can anyone tell me if there is a formula or coding that would tell one module to reference another? I am trying to get it where when it runs through my code and reaches a true statement then it would then go onto the next module and do the same. I am working with several sections in an excel worksheet so I am trying to keep my coding separate and clean. If anyone could help I would appreciate it. Thank You, Chris |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tie 2 or More Modules Together (vba)
I just wanted to thank everyone for there responses. It has helped me great deal. I am still learning this VB stuff and it is getting little easier. Granted I am still doing some pretty ugly programming. I think I have tripled my work though with some of the macros I hav configured. Again, Thank You all. Chris :) :cool -- zero63 ----------------------------------------------------------------------- zero635's Profile: http://www.excelforum.com/member.php...fo&userid=2480 View this thread: http://www.excelforum.com/showthread.php?threadid=38756 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Basic question - modules and class modules - what's the difference? | Excel Programming | |||
When to code in sheet or userform modules and when to use modules | Excel Programming | |||
modules | Excel Programming | |||
Modules | Excel Programming | |||
Class Modules vs Modules | Excel Programming |