G
Guest
regarding the following code, can anyone tell me when i redim arrx to be any bigger than (3,10), why i get an error when i try to call linest on the two arrays arrx, arry?
it works fine when the array is no bigger than (3,10), but if i extend it to say (4, 10) or (5,10), i get an error 2302...
any help would be appreciated
Sub Main()
Dim arrX(3, 10) As Double
Dim arrY(10) As Double
Dim Result As Variant
arrX(0, 0) = 2310
arrX(0, 1) = 2333
arrX(0, 2) = 2356
arrX(0, 3) = 2379
arrX(0, 4) = 2402
arrX(0, 5) = 2425
arrX(0, 6) = 2448
arrX(0, 7) = 2471
arrX(0, 8) = 2494
arrX(0, 9) = 2517
arrX(0, 10) = 2540
arrX(1, 0) = 2
arrX(1, 1) = 2
arrX(1, 2) = 3
arrX(1, 3) = 3
arrX(1, 4) = 2
arrX(1, 5) = 4
arrX(1, 6) = 2
arrX(1, 7) = 2
arrX(1, 8) = 3
arrX(1, 9) = 4
arrX(1, 10) = 2
arrX(2, 0) = 2
arrX(2, 1) = 2
arrX(2, 2) = 1.5
arrX(2, 3) = 2
arrX(2, 4) = 3
arrX(2, 5) = 2
arrX(2, 6) = 1.5
arrX(2, 7) = 2
arrX(2, 8) = 3
arrX(2, 9) = 4
arrX(2, 10) = 3
arrX(3, 0) = 20
arrX(3, 1) = 12
arrX(3, 2) = 33
arrX(3, 3) = 43
arrX(3, 4) = 53
arrX(3, 5) = 23
arrX(3, 6) = 99
arrX(3, 7) = 34
arrX(3, 8) = 23
arrX(3, 9) = 55
arrX(3, 10) = 22
'arrX(4, 0) = 20
'arrX(4, 1) = 12
'arrX(4, 2) = 33
'arrX(4, 3) = 43
'arrX(4, 4) = 53
'arrX(4, 5) = 23
'arrX(4, 6) = 99
'arrX(4, 7) = 34
'arrX(4, 8) = 23
'arrX(4, 9) = 55
'arrX(4, 10) = 22
'
'arrX(5, 0) = 20
'arrX(5, 1) = 12
'arrX(5, 2) = 33
'arrX(5, 3) = 43
'arrX(5, 4) = 53
'arrX(5, 5) = 23
'arrX(5, 6) = 99
'arrX(5, 7) = 34
'arrX(5, 8) = 23
'arrX(5, 9) = 55
'arrX(5, 10) = 22
arrY(0) = 142000
arrY(1) = 144000
arrY(2) = 151000
arrY(3) = 150000
arrY(4) = 139000
arrY(5) = 169000
arrY(6) = 126000
arrY(7) = 142900
arrY(8) = 163000
arrY(9) = 169000
arrY(10) = 149000
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
Result = xlApp.LinEst(arrY, arrX, True, True)
end sub
it works fine when the array is no bigger than (3,10), but if i extend it to say (4, 10) or (5,10), i get an error 2302...
any help would be appreciated
Sub Main()
Dim arrX(3, 10) As Double
Dim arrY(10) As Double
Dim Result As Variant
arrX(0, 0) = 2310
arrX(0, 1) = 2333
arrX(0, 2) = 2356
arrX(0, 3) = 2379
arrX(0, 4) = 2402
arrX(0, 5) = 2425
arrX(0, 6) = 2448
arrX(0, 7) = 2471
arrX(0, 8) = 2494
arrX(0, 9) = 2517
arrX(0, 10) = 2540
arrX(1, 0) = 2
arrX(1, 1) = 2
arrX(1, 2) = 3
arrX(1, 3) = 3
arrX(1, 4) = 2
arrX(1, 5) = 4
arrX(1, 6) = 2
arrX(1, 7) = 2
arrX(1, 8) = 3
arrX(1, 9) = 4
arrX(1, 10) = 2
arrX(2, 0) = 2
arrX(2, 1) = 2
arrX(2, 2) = 1.5
arrX(2, 3) = 2
arrX(2, 4) = 3
arrX(2, 5) = 2
arrX(2, 6) = 1.5
arrX(2, 7) = 2
arrX(2, 8) = 3
arrX(2, 9) = 4
arrX(2, 10) = 3
arrX(3, 0) = 20
arrX(3, 1) = 12
arrX(3, 2) = 33
arrX(3, 3) = 43
arrX(3, 4) = 53
arrX(3, 5) = 23
arrX(3, 6) = 99
arrX(3, 7) = 34
arrX(3, 8) = 23
arrX(3, 9) = 55
arrX(3, 10) = 22
'arrX(4, 0) = 20
'arrX(4, 1) = 12
'arrX(4, 2) = 33
'arrX(4, 3) = 43
'arrX(4, 4) = 53
'arrX(4, 5) = 23
'arrX(4, 6) = 99
'arrX(4, 7) = 34
'arrX(4, 8) = 23
'arrX(4, 9) = 55
'arrX(4, 10) = 22
'
'arrX(5, 0) = 20
'arrX(5, 1) = 12
'arrX(5, 2) = 33
'arrX(5, 3) = 43
'arrX(5, 4) = 53
'arrX(5, 5) = 23
'arrX(5, 6) = 99
'arrX(5, 7) = 34
'arrX(5, 8) = 23
'arrX(5, 9) = 55
'arrX(5, 10) = 22
arrY(0) = 142000
arrY(1) = 144000
arrY(2) = 151000
arrY(3) = 150000
arrY(4) = 139000
arrY(5) = 169000
arrY(6) = 126000
arrY(7) = 142900
arrY(8) = 163000
arrY(9) = 169000
arrY(10) = 149000
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
Result = xlApp.LinEst(arrY, arrX, True, True)
end sub