Call multiple Subs

DougStroud

Well-known Member
Joined
Aug 16, 2005
Messages
2,976
Office Version
  1. 365
Platform
  1. MacOS
A general question about Calls.

Calling a Sub from another Sub is quite common, how about a Sub that does nothing else but call all the subs to execute the entire job?

Will the subs run sequentially after one completes, or will there be the likley hood they will bump into each other causing all sorts of chaos...?
 
Functions do it all.

Function only returns value/object, can not change anything like Sub routine does.

Incidently jinden, I respectfully disagree with this statement. Functions, in fact, add the functionality to subs by having a return value. I can do anything in a function that I can do in a sub AND I get to return a value.

Functions don't force me to exchange functionality for return value; it's all VBA.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
KMillen,
That is a great idea.
I will experiment w/ this and post back.

Thanks
 
Upvote 0
Re: Functions do it all.

Function only returns value/object, can not change anything like Sub routine does.

Incidently jinden, I respectfully disagree with this statement. Functions, in fact, add the functionality to subs by having a return value. I can do anything in a function that I can do in a sub AND I get to return a value.

Functions don't force me to exchange functionality for return value; it's all VBA.

Can function:
Change format?
Change other cells' value?
Can add worksheets or workbooks?

What I meant is Function can not do anything by itself.
 
Upvote 0
That's a big YES to all of those questions!
Code:
Function WhatCanAFunctionDo()
'
' WhatCanAFunctionDo Macro
' Macro recorded 8/7/2007 by Kerry Millen
'
    
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "A"
    Selection.Font.ColorIndex = 3
    Selection.Font.Bold = True
    Range("B3").Select
    ActiveCell.FormulaR1C1 = "=CODE(R[-2]C[-1]) + 5"
    Range("B4").Select
    Sheets("Sheet1").Select
    Sheets.Add
End Function

Insert this code into an Excel sheet module and run it. A function can do everything a sub can do and return a value.
 
Upvote 0

Forum statistics

Threads
1,215,650
Messages
6,126,019
Members
449,280
Latest member
Miahr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top