Need help w/program to randomly sort row data

P

please respondhere

I've got an Excel worksheet with several columns of data. I want to randomly
shuffle all of the row data and then overwrite column A with sequential
numbers down the column, 1...X, where X is the last row. Any ideas?

Example:


1 B C D
2 G K L
3 D K C

might become

2 G K L
1 B C D
3 D K C

and then with column A renumbered, look like:

1 G K L
2 B C D
3 D K C


I don't know much about Excel at all. How can I develop such a thing.
Furthermore, can this also be done via a command line?

Thanks. If you have any ideas, please respond here.
 
D

David McRitchie

Hi ....,

I don't see any point to Column A, Excel has numbered
rows. You could use =ROW()

You can put random numbers in your Column E
E1: =RAND()
then select column E, Copy (ctrl+c), Paste special, values
Ctrl+A, Data, Sort, Column E ascending (no header row)

If you wanted to save a step you could use a macro
to generate a random number (decimal fraction).
To install and use see my getstarted.htm webpage

Sub RandomFraction()
'David McRitchie 2004-08-09 .excel
Dim cell As Range
Randomize ' Initialize random-number generator.
For Each cell In Selection
cell.Value = Rnd
Next cell
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top