Writing a UDF that returns an array is fairly simple. The main ideas:
1) The function needs to be dimensioned as a Variant (it will become a variant containing an array at the end).
2) You need to dimension an array to hold your result
3) At the end of the function, assign the function variant to be this result array.
The necessary code will look something like:
Like other built in array functions (LINEST(), FREQUENCY(), TRANSPOSE(), etc), this kind of UDF will be used by selecting the desired outputrange, entering the function, and confirming with ctrl-shift-enter. Like other array functions, it can be nested inside of an INDEX() function to access individual elements of the output array.
Bookmarks