LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
snv snv is offline
external usenet poster
 
Posts: 3
Default Getting #VALUE! while entering UDF as an array function

I am trying to enter my own function in an array formula context,
similar to any other pre defined funtion.
For example, let my array be
{1;4;9;16;25;36}
If I select a 6x1 range of cells and enter the formula
=SQRT({1;4;9;16;25;36})
with a ctrl+shift+enter
I get
1
2
3
4
5
6

Now I want to write a UDF that does the same thing

Function myUDF(Input As Variant) As Variant
myUDF = Input ^ 0.5
End Function

when I enter
=myUDF({1;4;9;16;25;36})
again, with ctrl+shift+enter

I get
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Interestingly enough when I enter
=myUDF(81)
I get
9

Had myUDF been

Function myUDF(Input As Variant) As Variant
myUDF = Input
End Function

IE, no modification, just return what I get
=myUDF({1;4;9;16;25;36})
returns
1
4
9
16
25
36

as expected.

The problem seems to be when I try to use myUDF in an array context
and I try to modify the input in any way. How can I get it to act
just like the
=SQRT({1;4;9;16;25;36})

And before anyone asks why I trying to emulate an already existing
function, this is just an example to illustrate the problem.

Please help and thanks in advance

Sean
 
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
Entering an array formula wthawaii Excel Worksheet Functions 2 August 28th 07 01:54 PM
entering as an array Alfonso Excel Discussion (Misc queries) 0 October 5th 06 04:48 PM
Entering Array Functions Jaytee Excel Discussion (Misc queries) 1 August 28th 05 04:11 PM
Entering Array Formula No Name Excel Programming 1 September 1st 04 02:04 PM
Programatically Entering an Array Formula John C.[_4_] Excel Programming 1 July 28th 04 01:53 AM


All times are GMT +1. The time now is 11:25 AM.

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

About Us

"It's about Microsoft Excel"