Function can not change the Excel environment.
Just for clarity, it should be said that a function (or sub)
called from a worksheet cell cannot change the Excel environment.
Functions, per se, can change the Excel environment. It is only
when they are called directly or indirectly from a worksheet cell
that the prohibition on changes comes in to play.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Frank Kabel" wrote in message
...
Hi Rob
one difference between sub and functions:
Function can not change the Excel environment. That is they
can't
change formats, other cells, etc. Only subs can do this.
Also have a look at http://www.cpearson.com/excel/differen.htm
--
Regards
Frank Kabel
Frankfurt, Germany
Rob van Gelder wrote:
Something that I've always been curious about, but never
found a real
reason behind.
Why do we use a Sub instead of using a Function?
Is there any reason other than a Sub returns nothing?
These both do exactly the same thing:
Function Test()
MsgBox "test"
End Function
Sub Test()
MsgBox "test"
End Sub
At the moment my opinion is that Sub is redundant and may as
well
never be used.
Thoughts? Comments?