Alan Moseley IT Consultancy

Blog Entry

9/23/2008 - Passing an array to a user-defined function (UDF) in .NET from Excel

I am in the middle of converting some Excel UDFs into a .NET addin, and could not see how to pass an array from Excel to my add-in. The answer was to declare the array as an object rather than any other sort of variable:-

Public Function MyFunction(ByVal MyArray As Object) As Object

To call the function from Excel you use the following syntax:-

=MyFunction({1,2,3})