#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default functions

dear all
I have two questions

1) How can I write a function that accepts multiple inputs (arguments) and
return multiple values? The straightforward method accepts multiple values
and returns a single value (that is the name of the function)

2) How can I write a function that accepts multiple arrays as input
arguments and returns an array too.

ex: if I have two arrays x , y
how can I configure a function f(x,y) that return an array representing the
pointwise multiplication of x,y
i.e f(i)= x(i)* y(i)

thanks in advance


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default functions

Public Function MultArray(x, y)
Dim f() As Double
ReDim f(LBound(x) To UBound(x))
For i = LBound(x) To UBound(x)
f(i) = x(i) * y(i)
Next
MultArray = f
End Function

Sub tester4()
Dim u As Variant
Dim x As Variant, y As Variant
x = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
y = Array(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)
u = MultArray(x, y)
For i = LBound(u) To UBound(u)
Debug.Print i, u(i)
Next

End Sub

Would be one possibility

--
Regards,
Tom Ogilvy





marwan hefnawy wrote in message
...
dear all
I have two questions

1) How can I write a function that accepts multiple inputs (arguments) and
return multiple values? The straightforward method accepts multiple values
and returns a single value (that is the name of the function)

2) How can I write a function that accepts multiple arrays as input
arguments and returns an array too.

ex: if I have two arrays x , y
how can I configure a function f(x,y) that return an array representing

the
pointwise multiplication of x,y
i.e f(i)= x(i)* y(i)

thanks in advance




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
How to convert cell formula functions to code functions Adnan Excel Discussion (Misc queries) 1 October 1st 08 08:30 PM
formula/functions for average and if functions Petu71 Excel Worksheet Functions 2 August 5th 07 08:25 PM
efficiency: database functions vs. math functions vs. array formula nickname Excel Discussion (Misc queries) 2 July 14th 06 04:26 AM
Looking for a site with functions that substitute the ATP functions Franz Verga Excel Worksheet Functions 3 June 24th 06 04:30 AM
Nesting functions in the functions dialog box cs170a Excel Worksheet Functions 0 June 10th 05 10:36 PM


All times are GMT +1. The time now is 01:40 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"