Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to return a value from a function?
Dear Excel Gurus,
In C, one can do the following; int func() { .... if (x == true) return y; .... } How can I do the same thing in Excel VBA? I wish to return a value and exit without running the function to the end. Thanks for your advice in advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to return a value from a function?
Function GetValue() as Long
Dim i as Long For i = 1 to 10 If i = 5 Then GetValue = i Exit Function End If Next i End Function So, the answer is Exit Function. RBS "Sing" wrote in message ... Dear Excel Gurus, In C, one can do the following; int func() { .... if (x == true) return y; .... } How can I do the same thing in Excel VBA? I wish to return a value and exit without running the function to the end. Thanks for your advice in advance. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to return a value from a function?
General ideas...
Function Func() Dim x As Boolean Dim y As Double x = True y = 3.14 If x Then Func = y Exit Function End If 'Other stuff Func = 1.23 End Function -- HTH :) Dana DeLouis Windows XP & Excel 2007 "Sing" wrote in message ... Dear Excel Gurus, In C, one can do the following; int func() { .... if (x == true) return y; .... } How can I do the same thing in Excel VBA? I wish to return a value and exit without running the function to the end. Thanks for your advice in advance. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to return a value from a function?
Thank you for your replies. You have been most helpful!!
"Sing" wrote in message ... Dear Excel Gurus, In C, one can do the following; int func() { .... if (x == true) return y; .... } How can I do the same thing in Excel VBA? I wish to return a value and exit without running the function to the end. Thanks for your advice in advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Return Function | Excel Worksheet Functions | |||
Return value for a function. | Excel Discussion (Misc queries) | |||
Why does this function NOT return a value? | Excel Discussion (Misc queries) | |||
Only do Sum function if not "0", IF"0" then return "0" | Excel Worksheet Functions | |||
Function to return value from each tab | Excel Worksheet Functions |