Error Converting Passed Range into Array in VBA for Excel
Your code (not counting the last bits that I don't have) worked ok for me.
Are you sure you're passing the range from the correct worksheet?
Kurt M. Sanger wrote:
For years I've been passing ranges into Excel functions, then converting them
into an array so that I can use them. But today I'm getting an empty array
instead of a full one. If I pass in a 4x4 array my function seems to work.
But when I pass in a 27x10 array I get nada. After the assignment "arrX =
arrayXIn.Value" the debugger shows arrX is the correct size but its empty.
Here's my code. Any suggestions?
Public Function funcExcelGenXXInv(arrayXIn As Range)
Dim arrX As Variant '27 x 10
Dim arrayXPrime As Variant '10 x 27
Dim arrayXpX As Variant '10 x 10
Dim arrayXpXInv As Variant '10 x 10
Dim intNRows, intNCols As Integer
arrX = arrayXIn.Value
'Find size of X array.
intNRows = UBound(arrX, 1)
intNCols = UBound(arrX, 2)
arrayXPrime = funcTranspose(arrX)
arrayXpX = funcMultM(arrayXPrime, arrX)
arrayXpXInv = funcInvMatrix(arrayXpX)
funcExcelGenXXInv = arrayXpXInv
End Function
--
Dave Peterson
|