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.
|