Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Excel Array Formula using C#

I'm trying to write a series of formulas which we can use in Excel reports to grab some data from our database so I wrote a function in c# which could be used in an array like so:


By putting this formula into an array of cells it should list all of the countries in the database, however it only appears to list the first country several times.

The c# method is basically returning a string array with the names of the countries and it works fine on it's own.

If I create a similar function in the VBA code of the Excel project it works fine. It would appear to be having trouble converting an array from c# into an array in VBA.

Anyone done anything like this before? Any ideas welcome.


Tuesday, June 14, 2005

fixed now. if anyone cares, the solution is that array formulas in Excel are 2 dimensional arrays and the 1st dimension is horizontal and the 1st is vertical. Hence to make an array formula which fills vertically down (which is what I was trying to do) you need to return and array of

string[x, 1]

rather than


Wednesday, June 15, 2005

*  Recent Topics

*  Fog Creek Home