Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 211
Default how to sort a column of Randomly selected numbers?

I have a column of numbers and want to choose some of them by random. First,
I generate a coulmn of random numbers by RAND function and in next column
select from them by following command:
INDEX($A$1:INDIRECT(C$72),RANK($B1,$B$1:INDIRECT(C $73)))
Now I want to sort these numbers (last column), let say Ascending. How can I
do this?
I am looking for a function or series of functions to perform sorting in a
different column without using Excel-built-in Sort commnad. The reason is
that, sort command doesn't work with randomly generated numbers, because each
time I try to use SORT command, Excel tries to regenerate them.
One poor solution is to copy/special paste (only values) the random numbers
and then use SORT command, but in this way I miss the regeneration function
of random numbers.
Any help is welcome
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default how to sort a column of Randomly selected numbers?

Set calculation to manual before sorting.

Tools|options & check manual

Mike

"Khoshravan" wrote:

I have a column of numbers and want to choose some of them by random. First,
I generate a coulmn of random numbers by RAND function and in next column
select from them by following command:
INDEX($A$1:INDIRECT(C$72),RANK($B1,$B$1:INDIRECT(C $73)))
Now I want to sort these numbers (last column), let say Ascending. How can I
do this?
I am looking for a function or series of functions to perform sorting in a
different column without using Excel-built-in Sort commnad. The reason is
that, sort command doesn't work with randomly generated numbers, because each
time I try to use SORT command, Excel tries to regenerate them.
One poor solution is to copy/special paste (only values) the random numbers
and then use SORT command, but in this way I miss the regeneration function
of random numbers.
Any help is welcome
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default how to sort a column of Randomly selected numbers?

If data is in Column C:

=SMALL($C$1:$C$10,ROW())

Copy down

"Khoshravan" wrote:

I have a column of numbers and want to choose some of them by random. First,
I generate a coulmn of random numbers by RAND function and in next column
select from them by following command:
INDEX($A$1:INDIRECT(C$72),RANK($B1,$B$1:INDIRECT(C $73)))
Now I want to sort these numbers (last column), let say Ascending. How can I
do this?
I am looking for a function or series of functions to perform sorting in a
different column without using Excel-built-in Sort commnad. The reason is
that, sort command doesn't work with randomly generated numbers, because each
time I try to use SORT command, Excel tries to regenerate them.
One poor solution is to copy/special paste (only values) the random numbers
and then use SORT command, but in this way I miss the regeneration function
of random numbers.
Any help is welcome
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 211
Default how to sort a column of Randomly selected numbers?

Yes it is a good idea as far as you dont forget to switch back to automatic
calculation. I was unaware of this method, but I think still there is a
better way of sorting a column of numbers.
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan


"Mike H" wrote:

Set calculation to manual before sorting.

Tools|options & check manual

Mike

"Khoshravan" wrote:

I have a column of numbers and want to choose some of them by random. First,
I generate a coulmn of random numbers by RAND function and in next column
select from them by following command:
INDEX($A$1:INDIRECT(C$72),RANK($B1,$B$1:INDIRECT(C $73)))
Now I want to sort these numbers (last column), let say Ascending. How can I
do this?
I am looking for a function or series of functions to perform sorting in a
different column without using Excel-built-in Sort commnad. The reason is
that, sort command doesn't work with randomly generated numbers, because each
time I try to use SORT command, Excel tries to regenerate them.
One poor solution is to copy/special paste (only values) the random numbers
and then use SORT command, but in this way I miss the regeneration function
of random numbers.
Any help is welcome
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 806
Default how to sort a column of Randomly selected numbers?

Hello,

SMALL does not work if data values are not unique.

A small example how it might work:
Enter into A1:B3:
37 =RAND()
13 =RAND()
57 =RAND()

Enter into C1:
=COUNTIF($B$1:$B$3,"<"&B1)+COUNTIF($B$1:B1,"="&B1)
and copy down to C3

If you now want to select 2 random values:
Enter into D1:
=INDEX($A$1:$A$3,MATCH(ROW(),$C$1:$C$3,))
and copy down to D2

Enter into E1:
=COUNTIF($D$1:$D$2,"<"&D1)+COUNTIF($D$1:D1,"="&D1)
and copy down to E2

Enter into F1:
=INDEX($D$1:$D$2,MATCH(ROW(),$E$1:$E$2,))
and copy down to F2

Columns B:D do the random selection, E:F sort the result.

This approach works also with text, not only with numbers. I suggest
to replace any SMALL or LARGE approach by the COUNTIF + COUNTIF
approach as shown above.

Regards,
Bernd



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10
Default how to sort a column of Randomly selected numbers?

In article . com,
Bernd P wrote:

Hello,

SMALL does not work if data values are not unique.

A small example how it might work:
Enter into A1:B3:
37 =RAND()
13 =RAND()
57 =RAND()

Enter into C1:
=COUNTIF($B$1:$B$3,"<"&B1)+COUNTIF($B$1:B1,"="&B1)
and copy down to C3

If you now want to select 2 random values:
Enter into D1:
=INDEX($A$1:$A$3,MATCH(ROW(),$C$1:$C$3,))
and copy down to D2

Enter into E1:
=COUNTIF($D$1:$D$2,"<"&D1)+COUNTIF($D$1:D1,"="&D1)
and copy down to E2

Enter into F1:
=INDEX($D$1:$D$2,MATCH(ROW(),$E$1:$E$2,))
and copy down to F2

Columns B:D do the random selection, E:F sort the result.

This approach works also with text, not only with numbers. I suggest
to replace any SMALL or LARGE approach by the COUNTIF + COUNTIF
approach as shown above.

Regards,
Bernd


Bernd -

SMALL() gives ties (non-uniques) the same place. If there are ties,
what difference can it make? Doesn't SMALL($B$1:$B$3,ROW()) go to the
same thing?

....best, Capt N.

--
Email to (yes, you can so figure it out) ;-]

Scream and shout and jump for joy! I was here before Kilroy!

Sorry to spoil your little joke. I was here but my computer broke. ---Kilroy
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default how to sort a column of Randomly selected numbers?

Try this:

=INDEX(rng,MATCH(SMALL(COUNTIF(rng,"<"&rng),ROWS($ 1:1)),COUNTIF(rng,"<"&rng),0))

ctrl+shift+enter, not just enter
copy down


"Khoshravan" wrote:

I have a column of numbers and want to choose some of them by random. First,
I generate a coulmn of random numbers by RAND function and in next column
select from them by following command:
INDEX($A$1:INDIRECT(C$72),RANK($B1,$B$1:INDIRECT(C $73)))
Now I want to sort these numbers (last column), let say Ascending. How can I
do this?
I am looking for a function or series of functions to perform sorting in a
different column without using Excel-built-in Sort commnad. The reason is
that, sort command doesn't work with randomly generated numbers, because each
time I try to use SORT command, Excel tries to regenerate them.
One poor solution is to copy/special paste (only values) the random numbers
and then use SORT command, but in this way I miss the regeneration function
of random numbers.
Any help is welcome
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 806
Default how to sort a column of Randomly selected numbers?

Hello,

If its only one numeric value then you are right: no difference. So in
this example it would work.

But in a more general case:
If you want to apply the random selection and the sort for attribute
values which are next to your index value, you will only find the
first index value. If the index value is non-numeric it would fail.

Regards,
Bernd

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 211
Default how to sort a column of Randomly selected numbers?

Thanks Toppers
It worked and it was very neat solution.
I read late replies which says it will not work and the replies to it. So I
think it is clear that it works as the numbers are unique.
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan


"Toppers" wrote:

If data is in Column C:

=SMALL($C$1:$C$10,ROW())

Copy down

"Khoshravan" wrote:

I have a column of numbers and want to choose some of them by random. First,
I generate a coulmn of random numbers by RAND function and in next column
select from them by following command:
INDEX($A$1:INDIRECT(C$72),RANK($B1,$B$1:INDIRECT(C $73)))
Now I want to sort these numbers (last column), let say Ascending. How can I
do this?
I am looking for a function or series of functions to perform sorting in a
different column without using Excel-built-in Sort commnad. The reason is
that, sort command doesn't work with randomly generated numbers, because each
time I try to use SORT command, Excel tries to regenerate them.
One poor solution is to copy/special paste (only values) the random numbers
and then use SORT command, but in this way I miss the regeneration function
of random numbers.
Any help is welcome
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan

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
How do I randomly sort data in a column? goody Excel Discussion (Misc queries) 1 October 2nd 06 03:36 PM
How do I sort randomly a list of 22 numbers Deal or No Deal game simulation Excel Discussion (Misc queries) 3 May 21st 06 10:27 AM
How to generate a list of randomly selected numbers within a range Bob Excel Worksheet Functions 2 November 7th 05 06:09 PM
can Excel randomly sort numbers gasmith Excel Discussion (Misc queries) 2 March 18th 05 11:14 PM
Randomly Sort a Series of Numbers Shoelaces Excel Discussion (Misc queries) 3 January 8th 05 07:25 PM


All times are GMT +1. The time now is 09:11 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"