Get Array Formula value for cell in Excel-DNA

1.2k views Asked by At

I have an Excel DNA Ribbon and a set of formulae that return arrays.

I'd like to add a button on the ribbon which expands an array formula out to the size of the data - much like this: http://excel-dna.net/2011/01/30/resizing-excel-udf-result-arrays/ but on the click of a button rather than when the UDF is run.

I have a reference to the cell:

        ExcelAsyncUtil.QueueAsMacro(
            () =>
            {
                ExcelReference current = XlCall.Excel(XlCall.xlfActiveCell) as ExcelReference;
            });

but don't know what to do from here. If I try to use object value = current.GetValue(); I just get the display value of the individual cell.

I tried to access the Formula but I don't want to have to evaluate every parameter individually.

Any ideas would be gratefully received.

1

There are 1 answers

0
Govert On

From the ribbon handler, it's probably easier to do this using the COM object model. Perhaps this post has some VBA that would give you a start: https://newtonexcelbach.wordpress.com/2015/04/14/re-sizing-array-functions/ In your Excel-DNA add-in, you get the root Application object with a call to ExcelDnaUtil.Application.