View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default 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