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