PC Review


Reply
Thread Tools Rate Thread

custom excel function returns array, showing #VALUE in cells

 
 
satishartham@gmail.com
Guest
Posts: n/a
 
      29th Nov 2007
I'm using a function that returns an array of data. I put in the
function name and hit ctrl-shift_enter and every cell in my selection
gets a #VALUE.

So I thought the function might be returning bad data. I put a
breakpoint in the debugger and I can see that the array being returned
has good data. The returned type is variant/string(0 to 499, 0 to
15). I've done some spot checking and the values look fine.

How can it be that the array looks fine in the debugger but i'm
getting #VALUE back in my cells?


thanks,

Satish
 
Reply With Quote
 
 
 
 
Bernard Liengme
Guest
Posts: n/a
 
      29th Nov 2007
Would you like to share the UDF with us?
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

<(E-Mail Removed)> wrote in message
news:b1c4c468-10ea-45ef-a90a-(E-Mail Removed)...
> I'm using a function that returns an array of data. I put in the
> function name and hit ctrl-shift_enter and every cell in my selection
> gets a #VALUE.
>
> So I thought the function might be returning bad data. I put a
> breakpoint in the debugger and I can see that the array being returned
> has good data. The returned type is variant/string(0 to 499, 0 to
> 15). I've done some spot checking and the values look fine.
>
> How can it be that the array looks fine in the debugger but i'm
> getting #VALUE back in my cells?
>
>
> thanks,
>
> Satish



 
Reply With Quote
 
Niek Otten
Guest
Posts: n/a
 
      29th Nov 2007
And the formula in which you call it from the worksheet, including the range selected

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Bernard Liengme" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
| Would you like to share the UDF with us?
| best wishes
| --
| Bernard V Liengme
| Microsoft Excel MVP
| www.stfx.ca/people/bliengme
| remove caps from email
|
| <(E-Mail Removed)> wrote in message
| news:b1c4c468-10ea-45ef-a90a-(E-Mail Removed)...
| > I'm using a function that returns an array of data. I put in the
| > function name and hit ctrl-shift_enter and every cell in my selection
| > gets a #VALUE.
| >
| > So I thought the function might be returning bad data. I put a
| > breakpoint in the debugger and I can see that the array being returned
| > has good data. The returned type is variant/string(0 to 499, 0 to
| > 15). I've done some spot checking and the values look fine.
| >
| > How can it be that the array looks fine in the debugger but i'm
| > getting #VALUE back in my cells?
| >
| >
| > thanks,
| >
| > Satish
|
|


 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      29th Nov 2007
You might want to post some code. You'll get a #VALUE result if your
function attempts to change any part of the Excel environment, including the
values of other cells. A function can only return a value or an array of
values to the cells from which it was called.

You might try changing the return type of the function to a Variant. E.g.,

Function MyFunction(....) As Variant

instead of an array.

See http://www.cpearson.com/Excel/Return...ysFromVBA.aspx for more info.



--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

<(E-Mail Removed)> wrote in message
news:b1c4c468-10ea-45ef-a90a-(E-Mail Removed)...
> I'm using a function that returns an array of data. I put in the
> function name and hit ctrl-shift_enter and every cell in my selection
> gets a #VALUE.
>
> So I thought the function might be returning bad data. I put a
> breakpoint in the debugger and I can see that the array being returned
> has good data. The returned type is variant/string(0 to 499, 0 to
> 15). I've done some spot checking and the values look fine.
>
> How can it be that the array looks fine in the debugger but i'm
> getting #VALUE back in my cells?
>
>
> thanks,
>
> Satish


 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      29th Nov 2007
Make sure you are using it as an array on the Worksheet and it has the
correct orientation:

Function demo(r As Range) As Variant
v = Array(1, 2, 3)
demo = v
End Function

Now on the worksheet, highlight A1 thru C1 and enter
=demo(Z100) and finish with CNTRL-SHFT-ENTER rather than just ENTER. You
will see:

1 2 3

If you had selected A1 thru A3 you will see:

1
1
1

because you need a transpose.
--
Gary''s Student - gsnu2007a


"(E-Mail Removed)" wrote:

> I'm using a function that returns an array of data. I put in the
> function name and hit ctrl-shift_enter and every cell in my selection
> gets a #VALUE.
>
> So I thought the function might be returning bad data. I put a
> breakpoint in the debugger and I can see that the array being returned
> has good data. The returned type is variant/string(0 to 499, 0 to
> 15). I've done some spot checking and the values look fine.
>
> How can it be that the array looks fine in the debugger but i'm
> getting #VALUE back in my cells?
>
>
> thanks,
>
> Satish
>

 
Reply With Quote
 
satishartham@gmail.com
Guest
Posts: n/a
 
      29th Nov 2007
On Nov 29, 3:51 pm, Gary''s Student
<GarysStud...@discussions.microsoft.com> wrote:
> Make sure you are using it as an array on the Worksheet and it has the
> correct orientation:
>
> Function demo(r As Range) As Variant
> v = Array(1, 2, 3)
> demo = v
> End Function
>
> Now on the worksheet, highlight A1 thru C1 and enter
> =demo(Z100) and finish with CNTRL-SHFT-ENTER rather than just ENTER. You
> will see:
>
> 1 2 3
>
> If you had selected A1 thru A3 you will see:
>
> 1
> 1
> 1
>
> because you need a transpose.
> --
> Gary''s Student - gsnu2007a
>
>
>
> "satishart...@gmail.com" wrote:
> > I'm using a function that returns an array of data. I put in the
> > function name and hit ctrl-shift_enter and every cell in my selection
> > gets a #VALUE.

>
> > So I thought the function might be returning bad data. I put a
> > breakpoint in the debugger and I can see that the array being returned
> > has good data. The returned type is variant/string(0 to 499, 0 to
> > 15). I've done some spot checking and the values look fine.

>
> > How can it be that the array looks fine in the debugger but i'm
> > getting #VALUE back in my cells?

>
> > thanks,

>
> > Satish- Hide quoted text -

>
> - Show quoted text -


Thanks for everyone's help but looks like I've found my answer:
http://support.microsoft.com/kb/250828. I tried the same function
call in WinXP and it's fine. My function was returning more data than
excel 2000 could handle.
 
Reply With Quote
 
satishartham@gmail.com
Guest
Posts: n/a
 
      29th Nov 2007
On Nov 29, 4:37 pm, satishart...@gmail.com wrote:
> On Nov 29, 3:51 pm, Gary''s Student
>
>
>
>
>
> <GarysStud...@discussions.microsoft.com> wrote:
> > Make sure you are using it as an array on the Worksheet and it has the
> > correct orientation:

>
> > Function demo(r As Range) As Variant
> > v = Array(1, 2, 3)
> > demo = v
> > End Function

>
> > Now on the worksheet, highlight A1 thru C1 and enter
> > =demo(Z100) and finish with CNTRL-SHFT-ENTER rather than just ENTER. You
> > will see:

>
> > 1 2 3

>
> > If you had selected A1 thru A3 you will see:

>
> > 1
> > 1
> > 1

>
> > because you need a transpose.
> > --
> > Gary''s Student - gsnu2007a

>
> > "satishart...@gmail.com" wrote:
> > > I'm using a function that returns an array of data. I put in the
> > > function name and hit ctrl-shift_enter and every cell in my selection
> > > gets a #VALUE.

>
> > > So I thought the function might be returning bad data. I put a
> > > breakpoint in the debugger and I can see that the array being returned
> > > has good data. The returned type is variant/string(0 to 499, 0 to
> > > 15). I've done some spot checking and the values look fine.

>
> > > How can it be that the array looks fine in the debugger but i'm
> > > getting #VALUE back in my cells?

>
> > > thanks,

>
> > > Satish- Hide quoted text -

>
> > - Show quoted text -

>
> Thanks for everyone's help but looks like I've found my answer:http://support.microsoft.com/kb/250828. I tried the same function
> call in WinXP and it's fine. My function was returning more data than
> excel 2000 could handle.- Hide quoted text -
>
> - Show quoted text -


Argh I meant Excel XP, not WinXP
 
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
Create Function which returns an Array ExcelMonkey Microsoft Excel Programming 8 24th Jun 2008 07:29 PM
How To: C++ DLL function returns Structure Array to VB .NET lov4mu6@gmail.com Microsoft VB .NET 0 16th Sep 2006 01:20 AM
Function that returns an array? The.Relinator@gmail.com Microsoft C# .NET 6 16th Aug 2006 03:42 PM
Excel returns @name? error when using a custom written function in =?Utf-8?B?QWwgTWFoZXI=?= Microsoft Excel Programming 2 13th Apr 2006 01:31 PM
Function Returns Multidim Array =?Utf-8?B?TXVycA==?= Microsoft Access VBA Modules 3 15th Sep 2005 07:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 PM.