muppetgeoff
New member
- Local time
- Today, 16:26
- Joined
- Aug 9, 2004
- Messages
- 9
Hi All,
Please forgive me if this is a stupid question, I am new to VBA.
I was just wondering if someone could explain simply, the difference between a Public 'Function' and a Public 'Sub'.
Specifically, when the use of each is recommended, and how they differ from each other.
The only difference I can see, is how they handle the passing of results in and out of the process.
Subs seem to hand back a result, as long as the variable referenced is the same as the one that contains the result of the sub.
Functions seem to require you to hand back the result as a variable.
Am I way off on that observation?
The main reason for asking, is that I modified a 'Public Function' written by a user here, changed it to a 'Public Sub' and changed a lot of the methodology. As a 'Function' it didn't seem to work properly, but as a 'Sub' it did.
So I'm curious as to the actual difference.
Many thanks in advance,
Geoff
Please forgive me if this is a stupid question, I am new to VBA.
I was just wondering if someone could explain simply, the difference between a Public 'Function' and a Public 'Sub'.
Specifically, when the use of each is recommended, and how they differ from each other.
The only difference I can see, is how they handle the passing of results in and out of the process.
Subs seem to hand back a result, as long as the variable referenced is the same as the one that contains the result of the sub.
Functions seem to require you to hand back the result as a variable.
Am I way off on that observation?
The main reason for asking, is that I modified a 'Public Function' written by a user here, changed it to a 'Public Sub' and changed a lot of the methodology. As a 'Function' it didn't seem to work properly, but as a 'Sub' it did.
So I'm curious as to the actual difference.
Many thanks in advance,
Geoff