Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
I posted this question earlier but I think I was unclear. I am trying to use a function (maybe it is technically a macro - I dont know)- here is my problem. The function has 3 "input" variables declared as doubles, and based on these values the function assigns values to 3 output "variables". The output variables are declared inside the function - so I just want to get them - without declaring global variables. So in the code below I want to get variables "var1, var2, var3" - since they are the result of the TestFunction. Sub MainTest() Dim get1 As Double Dim get2 As Double Dim get3 As Double Call TestFunct1(1, 2, 3) End Sub Sub TestFunct1(X, Y, Z) Dim var1 As Double Dim var2 As Double Dim var3 As Double var1 = 1 * X var2 = 2 * Y var3 = 3 * Z End Sub Thanks for your help. |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
As my reply to your first posting:
Declare Var1 etc BEFORE Sub MainTest Dim var1 As Double Dim var2 As Double Dim var3 As Double Sub MainTest() Call TestFunct1(1, 2, 3) Debug.Print var1 & " " & var2 & " " & var3 End Sub Sub TestFunct1(X, Y, Z) var1 = 1 * X var2 = 2 * Y var3 = 3 * Z End Sub "Jeff" wrote: Hi, I posted this question earlier but I think I was unclear. I am trying to use a function (maybe it is technically a macro - I dont know)- here is my problem. The function has 3 "input" variables declared as doubles, and based on these values the function assigns values to 3 output "variables". The output variables are declared inside the function - so I just want to get them - without declaring global variables. So in the code below I want to get variables "var1, var2, var3" - since they are the result of the TestFunction. Sub MainTest() Dim get1 As Double Dim get2 As Double Dim get3 As Double Call TestFunct1(1, 2, 3) End Sub Sub TestFunct1(X, Y, Z) Dim var1 As Double Dim var2 As Double Dim var3 As Double var1 = 1 * X var2 = 2 * Y var3 = 3 * Z End Sub Thanks for your help. |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
How about something like:
Option Explicit Sub MainTest() Dim get1 As Double Dim get2 As Double Dim get3 As Double get1 = 1 get2 = 2 get3 = 3 Call TestFunct1(get1, get2, get3) MsgBox get1 & vbLf & get2 & vbLf & get3 End Sub Sub TestFunct1(ByRef x As Double, ByRef Y As Double, ByRef Z As Double) x = 1 * x Y = 2 * Y Z = 3 * Z End Sub (ByRef is VBA's default and isn't required.) Jeff wrote: Hi, I posted this question earlier but I think I was unclear. I am trying to use a function (maybe it is technically a macro - I dont know)- here is my problem. The function has 3 "input" variables declared as doubles, and based on these values the function assigns values to 3 output "variables". The output variables are declared inside the function - so I just want to get them - without declaring global variables. So in the code below I want to get variables "var1, var2, var3" - since they are the result of the TestFunction. Sub MainTest() Dim get1 As Double Dim get2 As Double Dim get3 As Double Call TestFunct1(1, 2, 3) End Sub Sub TestFunct1(X, Y, Z) Dim var1 As Double Dim var2 As Double Dim var3 As Double var1 = 1 * X var2 = 2 * Y var3 = 3 * Z End Sub Thanks for your help. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Use function output as a cell reference | Excel Worksheet Functions | |||
How can I output VBA function results (array's for example) to spreadsheet | Excel Worksheet Functions | |||
Reverse output of the Linest function | Excel Worksheet Functions | |||
Function/ formula to output a cell reference | Excel Worksheet Functions | |||
Excel should have a function to output T Stat | Excel Worksheet Functions |