![]() |
Returning an integer from a Function
I am trying to return a variable that I have given a value within a function.
example: VarX = 10 and then I put in "return VarX" and I keep getting a compile error. Is there another way of returning the value in vba? |
Returning an integer from a Function
Function Example (Arg1 as Double) As Double
Example = Arg1*2 End Function "WannaBeExceller" wrote in message ... I am trying to return a variable that I have given a value within a function. example: VarX = 10 and then I put in "return VarX" and I keep getting a compile error. Is there another way of returning the value in vba? |
Returning an integer from a Function
Of course in my example Double should have been Long
Don't use Integers, use Longs (32 bits) -- Kind regards, Niek Otten "WannaBeExceller" wrote in message ... I am trying to return a variable that I have given a value within a function. example: VarX = 10 and then I put in "return VarX" and I keep getting a compile error. Is there another way of returning the value in vba? |
Returning an integer from a Function
You don't need the Return key word
Public Function MyFunction () as integer dim varX as integer varX = 10 MyFunction = varX End Function -- HTH... Jim Thomlinson "WannaBeExceller" wrote: I am trying to return a variable that I have given a value within a function. example: VarX = 10 and then I put in "return VarX" and I keep getting a compile error. Is there another way of returning the value in vba? |
Returning an integer from a Function
Thank you very much guys. Worked like a charm!!
|
All times are GMT +1. The time now is 05:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com