ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   possible until 5461 (https://www.excelbanter.com/excel-programming/321967-possible-until-5461-a.html)

tom taol

possible until 5461
 

sub ex()
n = 5462

ReDim aRnd(1 To n)
ReDim uniq(1 To n)

For i = 1 To n: aRnd(i) = i: Next

For i = n To 2 Step -1
k = Int(Rnd * i) + 1
n_cnt = n_cnt + 1
uniq(n_cnt) = aRnd(k)
aRnd(k) = aRnd(i)
Next

uniq(n) = aRnd(1)
Range("b1:b" & n).Value = Application.Transpose(uniq)
end sub

why error?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

RB Smissaert

possible until 5461
 
This is a known limitation.
Go to this website:
http://home.pacbell.net/beban/
Download the arrayfunctions and use the function ArrayTranspose for this
purpose.

RBS


"tom taol" wrote in message
...

sub ex()
n = 5462

ReDim aRnd(1 To n)
ReDim uniq(1 To n)

For i = 1 To n: aRnd(i) = i: Next

For i = n To 2 Step -1
k = Int(Rnd * i) + 1
n_cnt = n_cnt + 1
uniq(n_cnt) = aRnd(k)
aRnd(k) = aRnd(i)
Next

uniq(n) = aRnd(1)
Range("b1:b" & n).Value = Application.Transpose(uniq)
end sub

why error?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



tom taol

possible until 5461
 


very thank you !!!
happy to you

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

possible until 5461
 
Faster and simpler than transposing or using Alan's code would be

sub ex()
n = 5462

ReDim aRnd(1 To n)
ReDim uniq(1 To n, 1 to 1)

For i = 1 To n: aRnd(i) = i: Next

For i = n To 2 Step -1
k = Int(Rnd * i) + 1
n_cnt = n_cnt + 1
uniq(n_cnt,1) = aRnd(k)
aRnd(k) = aRnd(i)
Next

uniq(n,1) = aRnd(1)
Range("b1:b" & n).Value = uniq
end sub

--
Regards,
Tom Ogilvy


"tom taol" wrote in message
...


very thank you !!!
happy to you

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




tom taol

possible until 5461
 


thank you(tom) very much.
i knew the reason for your help.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com