For example, suppose I have
{={1,2,3,4,5}}
in a cell. Is there any way to find out how many elements are in that array, and what those elements are?
Now implementing @chris neilsen’s idea, I’ve now got a VBA function as below
Function rinfo(r As Range) As String
With r.CurrentArray
rinfo = .Address & ", " & .Rows.Count & ", " & .Columns.Count & ", " & .Value & ", " & .Value2
End With
End Function
however the data from it doesn’t look to hopeful, viz
$A$29, 1, 1, 1, 1
The Rows.Count and Columns.Count make sense if they are counting the rows and cols used in the worksheet. But as an indication of the data in the array formula, no.
Your formula only occupies a single cell, and a cell can only contain a scalar value, so after the cell has been calculated it will contain 1.
But you can evaluate the formula from VBA and that can give you an array result. If your formula is in A1 then
will result in vArr containing an array of of 4 variants of the 4 numbers.
There are several “quirks” to the Evaluate method: see one of my web pages for details.