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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call another Sub Procedure from within Main Sub 1

Status
Not open for further replies.

hotbread

Technical User
Mar 13, 2006
42
AU
Hello.... I'm not sure how to word this exactly, but I'm trying to find out how to call and run a sub procedure from within the main sub of the macro being run.

Below is a very simplistic version of what I want to achieve, but the 'Call' line doesn't do anything, and I'm not sure what I need to do. Can anyone help me? I assume it may be a very basic thing to do, so I hope you'll forgive my ignorance.

Sub Main()
Call InputSecurities()
End Sub

Sub InputSecurities()

End Sub
 
declare Sub Number2()

Sub Main
msgbox "first"
Number2
End Sub

Sub Number2()
msgbox "second"
End Sub

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
You can do this too:

Sub InputSecurities()

End Sub

Sub Main()
Call InputSecurities()
End Sub

The sub your calling can either be declared before the code calling it or written before the code calling it.
 
Cool... thanks Skie.... I'll have to give that one a try too once I get back to work on Monday.

Have a great weekend guys! (Friday night here Down Under!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top