Thread: Sub vs Function
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Sub vs Function

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?