Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Using a function
Hi,
I want a function to return a value, but it is not working. Here is my code. Sub NewTest() v = 1: j = 9 x = TestFunction(v, j) End Sub Sub TestFunction(x, y) TestFunction = x ^ 2 + y End Sub Error Message = "compile error, expected function or variable", highligted -- "x = TestFunction(v, j)" Does anyone know how to fix this? Thanks for your help. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Using a function
use
Function TestFunction(x, y) rather than Sub TestFunction(x, y) -- Gary''s Student "Jeff" wrote: Hi, I want a function to return a value, but it is not working. Here is my code. Sub NewTest() v = 1: j = 9 x = TestFunction(v, j) End Sub Sub TestFunction(x, y) TestFunction = x ^ 2 + y End Sub Error Message = "compile error, expected function or variable", highligted -- "x = TestFunction(v, j)" Does anyone know how to fix this? Thanks for your help. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Using a function
Duh!
I should have seen that - Thanks "Gary''s Student" wrote: use Function TestFunction(x, y) rather than Sub TestFunction(x, y) -- Gary''s Student "Jeff" wrote: Hi, I want a function to return a value, but it is not working. Here is my code. Sub NewTest() v = 1: j = 9 x = TestFunction(v, j) End Sub Sub TestFunction(x, y) TestFunction = x ^ 2 + y End Sub Error Message = "compile error, expected function or variable", highligted -- "x = TestFunction(v, j)" Does anyone know how to fix this? Thanks for your help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need some comments on my Utility_Move class module. | Excel Worksheet Functions | |||
Creating a Custom Excel Function to Calculate Gini Coefficients | Excel Worksheet Functions | |||
Date & Time | New Users to Excel | |||
Conversion | Excel Worksheet Functions | |||
HOW CAN I GET OFFICE 2003 EXCEL BASIC TO NEST FUNCTIONS LIKE EXCE. | Excel Worksheet Functions |