Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling sub functions

Status
Not open for further replies.
Dec 13, 2002
109
GB
Hello everyone

Ive got a now rather large vba sub called (originally main):
sub main()

I want to break it up into sub proceduresso I may have:
sub main()
sub 1()
sub 2()
sub 3() etc etc.

My question is if sub main () is my top level sub (i.e the first one to execute on entering the macro) how do i call other subs from it and do i need to declare them before sub main, after sub main or within sub main?

Cheers

Ronald
 
Ok Skip thats great, just one other question - where do i define the individual subs variables? Within each sub definition or in the main sub?

Cheers

Ronald
 
depends if you want the variables to be available to all subs or not. If so, you will need to define them as PUBLIC variables, BEFORE any of your subs Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Ok Geoff, so basically global variables are best preceded with public. In that case does private limit variable scope to a given sub? That makes sense to me if it doees.

Ronald


Im having an intensive couple of days with this vba stuff!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top