#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 921
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 921
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some comments on my Utility_Move class module. jchen Excel Worksheet Functions 0 August 21st 06 07:05 PM
Creating a Custom Excel Function to Calculate Gini Coefficients [email protected] Excel Worksheet Functions 3 February 21st 06 10:15 PM
Date & Time mully New Users to Excel 4 May 23rd 05 11:56 AM
Conversion SVC Excel Worksheet Functions 9 February 28th 05 02:29 PM
HOW CAN I GET OFFICE 2003 EXCEL BASIC TO NEST FUNCTIONS LIKE EXCE. Robert AS Excel Worksheet Functions 4 December 2nd 04 10:49 AM


All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"