Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default 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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default 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!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default 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!
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



All times are GMT +1. The time now is 03:17 PM.

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"