ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sub Vs. Function (https://www.excelbanter.com/excel-programming/398151-sub-vs-function.html)

Mike H.

Sub Vs. Function
 
Would someone please be so kind as to compare and contrast the differences
between a sub and a function. Thank you.

Chip Pearson

Sub Vs. Function
 
A Function procedure can return a result to the calling procedure, while a
Sub procedure does not return a result:

Sub AAA()
Dim L As Long
L = MyFunction(2)
MsgBox L
End Sub

Function MyFunction (T As Long)
MyFunction = T * 10
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Mike H." wrote in message
...
Would someone please be so kind as to compare and contrast the differences
between a sub and a function. Thank you.




All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com