View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default 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.