PC Review


Reply
Thread Tools Rate Thread

Can I write a function like matrix function?

 
 
=?Utf-8?B?RXZhbHVhdGUgZnVuY3Rpb24gcGFyYW1ldGVyIGFz
Guest
Posts: n/a
 
      22nd Jul 2007
Dear all
I want make a function which can be used in excel cell just like "=aaaa(x,
y)", and the result of function is a matrix, maybe 1x10, 10x1, 10x20 etc.

I tried to use the left-up cell of the output range as the additional
input paramter, just like "=aaaa(x,y, F10)"

Unfortunately, I CANNOT write any number to the output range....but I can
read data from the input cell

Function aaaa(x as double, y as double, output as Range) as boolean
x = output.range("A1").value ' this will WORK
output.range("A1").value = 10 ' this will FAIL
End Function


How can I return a matrix??
thanks~~
Sincerely.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      22nd Jul 2007
You assign the output to the function name - not as a parameter value.


You then have to do a multicell array entry of the formula in the worksheet

Function MyDumFunc(a as long)
redim v(1 to 10, 1 to 3)
for i = 1 to 10
for j = 1 to 3
v(i,j) = i * j * a
Next j
next i
MyDumFunc = v
End Function

Select A1:C10
in the formula bar put in

=MyDumFunc(25) and enter with Ctrl+Shift+Enter

--
Regards,
Tom Ogilvy



"Evaluate function parameter as VBA code" wrote:

> Dear all
> I want make a function which can be used in excel cell just like "=aaaa(x,
> y)", and the result of function is a matrix, maybe 1x10, 10x1, 10x20 etc.
>
> I tried to use the left-up cell of the output range as the additional
> input paramter, just like "=aaaa(x,y, F10)"
>
> Unfortunately, I CANNOT write any number to the output range....but I can
> read data from the input cell
>
> Function aaaa(x as double, y as double, output as Range) as boolean
> x = output.range("A1").value ' this will WORK
> output.range("A1").value = 10 ' this will FAIL
> End Function
>
>
> How can I return a matrix??
> thanks~~
> Sincerely.

 
Reply With Quote
 
=?Utf-8?B?RXZhbHVhdGUgZnVuY3Rpb24gcGFyYW1ldGVyIGFz
Guest
Posts: n/a
 
      23rd Jul 2007
thanks a lot~~~


"Tom Ogilvy" wrote:

> You assign the output to the function name - not as a parameter value.
>
>
> You then have to do a multicell array entry of the formula in the worksheet
>
> Function MyDumFunc(a as long)
> redim v(1 to 10, 1 to 3)
> for i = 1 to 10
> for j = 1 to 3
> v(i,j) = i * j * a
> Next j
> next i
> MyDumFunc = v
> End Function
>
> Select A1:C10
> in the formula bar put in
>
> =MyDumFunc(25) and enter with Ctrl+Shift+Enter
>
> --
> Regards,
> Tom Ogilvy
>
>
>
> "Evaluate function parameter as VBA code" wrote:
>
> > Dear all
> > I want make a function which can be used in excel cell just like "=aaaa(x,
> > y)", and the result of function is a matrix, maybe 1x10, 10x1, 10x20 etc.
> >
> > I tried to use the left-up cell of the output range as the additional
> > input paramter, just like "=aaaa(x,y, F10)"
> >
> > Unfortunately, I CANNOT write any number to the output range....but I can
> > read data from the input cell
> >
> > Function aaaa(x as double, y as double, output as Range) as boolean
> > x = output.range("A1").value ' this will WORK
> > output.range("A1").value = 10 ' this will FAIL
> > End Function
> >
> >
> > How can I return a matrix??
> > thanks~~
> > Sincerely.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
function with matrix xavi garriga Microsoft Excel Programming 4 18th Apr 2009 11:26 PM
how do you write format results of a function within a function? =?Utf-8?B?c2FuZ2Vl?= Microsoft Excel Worksheet Functions 3 14th Jun 2007 12:45 AM
UDF function on Matrix =?Utf-8?B?QXJydW4=?= Microsoft Excel Programming 1 26th Dec 2006 10:51 AM
how do I write a vlookup function within an iserror function so t. =?Utf-8?B?SkJMZWVkcw==?= Microsoft Excel Worksheet Functions 2 16th Mar 2005 10:30 AM
Matrix Function Operations Lewis Clark Microsoft Excel Worksheet Functions 2 5th Jan 2004 10:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:46 PM.