application transpose large array

MetLife

Active Member
Joined
Jul 2, 2012
Messages
283
hi,

i want to take an array and transpose it but am having issues. the problem appears to be the size of the array, does anyone know a fix?




Sub stochastic()
'commutation functions
Dim surv(1 To 100000) As Double
Dim survv(1 To 100) As Double
Dim i As Long, j As Long


For i = 1 To 10000
If i > 99 Then
j = 99
Else
j = i
End If
surv(i) = Rnd
survv(j) = Rnd
Next i
Range("b2:b10000") = Application.Transpose(surv) 'error type mismatch
Range("b2:b100") = Application.Transpose(survv) 'no error

end sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Code works fine for me, even when I increase the size of the arrays/ranges tenfold.
 
Upvote 0
for me the sizes work below the following
Dim surv(1 To 65536) As Double

but one larger and it crashes
Dim surv(1 To 65537) As Double

I am using excel 2010 on a 64bit macine, windows 10
 
Upvote 0
I just reran in a new workbook and still get an error

"type mismatch"

are you running the exact code I have?
Is the code you posted exactly the code you are using? I ask because you dimensioned your array for 100,000 elements but your loop is only filling 10,000 elements and you are only trying to transpose 10,000 values. The Transpose function has a maximum limit (cannot be overridden) of 65535 elements that it can transpose.
 
Upvote 0
Hallo,

too slow, Rick was faster.

Proposal:

Code:
dim surv(1 to 100000, 0 to 1)

Then Range("A1").resize(ubound(surv),ubound(surv,2)) = surv

will work.

regards
 
Last edited:
Upvote 0
Hallo,

too slow, Rick was faster.

Proposal:

Code:
dim surv(1 to 100000, 0 to 1)

Then Range("A1").resize(ubound(surv),ubound(surv,2)) = surv

will work.

regards

Well this works, so thank you!

Wonder what the issue was, are you able to run the original code?
 
Upvote 0
Is the code you posted exactly the code you are using? I ask because you dimensioned your array for 100,000 elements but your loop is only filling 10,000 elements and you are only trying to transpose 10,000 values. The Transpose function has a maximum limit (cannot be overridden) of 65535 elements that it can transpose.

OK thanks for that information Rick.
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,284
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top