As part of a VBA function I am outputting a large array by implicitly converting an array to a variant which I then output in an array formula. Although I am using Excel 2007, I seem to get #VALUE! errors when I dimension this with any more than 65,536 rows (also when I dimension using more than 65536 columns but only output part of the array so that it fits on the worksheet I also get these errors). I attach the code below. Is this a limit in Excel, or is there a workround?
Thanks for anyone who might be able to help
Function genarray(rows As Long, columns As Long) As Variant
Dim r As Long
Dim c As Long
ReDim x(1 To rows, 1 To columns) As Double
For r = 1 To rows
For c = 1 To columns
x(r, c) = r + c
Next c
Next r
genarray = x
End Function
Thanks for anyone who might be able to help
Function genarray(rows As Long, columns As Long) As Variant
Dim r As Long
Dim c As Long
ReDim x(1 To rows, 1 To columns) As Double
For r = 1 To rows
For c = 1 To columns
x(r, c) = r + c
Next c
Next r
genarray = x
End Function