ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a sub within a function (https://www.excelbanter.com/excel-programming/444711-using-sub-within-function.html)

Subodh

Using a sub within a function
 
I want to use a function to get from a sub.
For example:
sub x(y as variant)
y=activecell.offset(1,0).value+5
end sub
Now, I want to get a function

Function myfun(z as integer)
tmp=x(z)
myfun=tmp
end function

Jim Cone[_2_]

Using a sub within a function
 

Sub x(y As Integer)
y = ActiveCell.Offset(1, 0).Value + 5
End Sub

Function myfun(z As Integer) As Integer
Call x(z)
myfun = z
End Function

--
Jim Cone
Portland, Oregon USA .
http://www.mediafire.com/PrimitiveSoftware .
(Permutations Add-in: with option to highlight valid words)




"Subodh"
wrote in message
...
I want to use a function to get from a sub.
For example:


sub x(y as variant)
y=activecell.offset(1,0).value+5
end sub
Now, I want to get a function

Function myfun(z as integer)
tmp=x(z)
myfun=tmp
end function





All times are GMT +1. The time now is 03:00 PM.

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