UDF Array returning functions, size and #N/A values issues

166 views
Skip to first unread message

geremia.lo...@gmail.com

unread,
Sep 26, 2017, 9:07:39 AM9/26/17
to Excel-DNA
Hello everyone,
I'm new to exceldna and I'm doing a project that heavily uses it, integrating it in an excel Addin
I managed to define several functions which return 2D variable sized arrays
The problem is that with ctrl+shift+enter I have to know before the x-dimension of my returned matrix so i have plenty of #N/A values on the lower part of my matrix because I have to overstimate the dimension, otherwise not every value is shown

The pic shows best my problem, i just want the #N/A cells to be empty and to Excel not allocating memory with useless cells

Thank you
Capture.PNG

Govert van Drimmelen

unread,
Sep 26, 2017, 9:16:02 AM9/26/17
to exce...@googlegroups.com

My best suggestion is to use a helper macro that will resize your result array to the right size.

 

An example implementation can be found here: https://github.com/Excel-DNA/ExcelDna/blob/master/Distribution/Samples/ArrayResizer.dna

 

An alternative is to check the size of the caller inside your function, and pad the result array with empty string to the size of the calling range.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

geremia.lo...@gmail.com

unread,
Sep 26, 2017, 9:29:55 AM9/26/17
to Excel-DNA
thank you, i'll start to try your solution, anyway my 2D array is always the right size, it changes as the number of results increase or decrease.
 The area I select with my mouse to insert the function though, is always the same though
so if by resizing the array you mean the area, this solution could be the one I'm looking for

geremia.lo...@gmail.com

unread,
Sep 26, 2017, 10:02:40 AM9/26/17
to Excel-DNA
it worked, thank you again

DanyM

unread,
Jan 26, 2018, 8:15:48 AM1/26/18
to Excel-DNA
Hi geremia
can you post a demo of your working code ? i'm facing the same issue.
thank you
Reply all
Reply to author
Forward
0 new messages