Executing the procedure from another procedure
You can also execute a procedure from another procedure. Follow these steps if you want to give this a try:
1. Activate the VBA module that holds the CubeRoot routine.
2. Enter this new procedure (either above or below CubeRoot code — it makes no difference):
Sub NewSub()
Call CubeRoot
End Sub
3. Execute the NewSub macro.
The easiest way to do this is to move the cursor anywhere within the NewSub code and press F5. Notice that this NewSub procedure simply executes the CubeRoot procedure.
By the way, the keyword Call is optional. The statement can consist of only the Sub procedure’s name. I find, however, that using the Call keyword makes it perfectly clear that a procedure is being called.
No comments:
Post a Comment