Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Error Converting Passed Range into Array in VBA for Excel

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

The following works fine for me in xl2000

Sub Test12345()
Dim arr2
arr2 = funcExcelGenXXInv(Range("A1:J27"))
End Sub

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)
Debug.Print intNRows, intNCols, arrX(1, 4)

'arrayXPrime = funcTranspose(arrX)
'arrayXpX = funcMultM(arrayXPrime, arrX)
'arrayXpXInv = funcInvMatrix(arrayXpX)
'funcExcelGenXXInv = arrayXpXInv
End Function

If I change the calling procedure to

Set rng = Range("A1:J27")
arr2 = funcExcelGenXXInv(rng)

then I need to change the function to

Public Function funcExcelGenXXInv(ByVal arrayXIn As Range)

Alan Beban
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Converting Passed Range into Array in VBA for Excel Dave Peterson[_3_] Excel Programming 0 September 1st 04 01:17 AM
Redim 2D Array Subscript Out Of Range Error lopsided[_10_] Excel Programming 6 February 11th 04 08:24 AM
Subscript Out of Range error in Array... Kevin Lyons Excel Programming 3 February 4th 04 06:17 PM
Converting Range.value(error) vikrampn[_2_] Excel Programming 1 December 18th 03 12:03 AM
Find size of array passed to user-defined function Cliff[_2_] Excel Programming 2 October 21st 03 02:09 AM


All times are GMT +1. The time now is 05:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"