Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Random Sorting

Can anyone help?

I have a sheet with the following data:

Item, Price1, Price2, Price3, Price4,


I want to sort the prices for each item randomly but not sorting the whole
col together but sorting row for row eg.

Item, Price3, Price2, Price4, Price1,

Item, Price2, Price4, Price3, Price1,

Item, Price1, Price2, Price3, Price4,

And so on down the rows.

I can sort the whole col. by using a rnd. number but that wont help as my
prices are from low to high and I need them to be scattered but still
relating
to the correct items.

Many thanks in advance,

Des


  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 184
Default Random Sorting

Hi,

pls run the enclosed macro on an empty sheet. (The macro is recorded
'cause i do not know the functions in english, you only need the
resulting formulas in the sheet.)

columns A to E show what you want, the rest is used for construction.
The prices will be sorted on every change you make in the sheet.

columns F to I show random numbers (random*random = very unlikely to
get the same number twice (which would mean same rank)). columns J to M
show the rank of the random numbers, columns O to R are your 4 prices.

read help to rank(), rand(), offset() functions.

regards

arno



Sub Makro1()
Cells(7, 1).Select
ActiveCell.FormulaR1C1 = "item"
Range("F7").Select
ActiveCell.FormulaR1C1 = "=RAND()*RAND()"
Range("G7").Select
ActiveCell.FormulaR1C1 = "=RAND()*RAND()"
Range("H7").Select
ActiveCell.FormulaR1C1 = "=RAND()*RAND()"
Range("I7").Select
ActiveCell.FormulaR1C1 = "=RAND()*RAND()"
Range("J7").Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-4],R7C6:R7C9)"
Range("K7").Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-4],R7C6:R7C9)"
Range("L7").Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-4],R7C6:R7C9)"
Range("L8").Select
ActiveWindow.SmallScroll ToRight:=1
Range("M7").Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-4],R7C6:R7C9)"
Range("M8").Select
ActiveWindow.SmallScroll ToRight:=6
Range("O7").Select
ActiveCell.FormulaR1C1 = "a"
Range("P7").Select
ActiveCell.FormulaR1C1 = "b"
Range("Q7").Select
ActiveCell.FormulaR1C1 = "c"
Range("R7").Select
ActiveCell.FormulaR1C1 = "d"
Range("R8").Select
ActiveWindow.LargeScroll ToRight:=-1
Range("B7").Select
ActiveCell.FormulaR1C1 = "=OFFSET(RC14,0,RC[8],1,1)"
Range("C7").Select
ActiveCell.FormulaR1C1 = "=OFFSET(RC14,0,RC[8],1,1)"
Range("D7").Select
ActiveCell.FormulaR1C1 = "=OFFSET(RC14,0,RC[8],1,1)"
Range("E7").Select
ActiveCell.FormulaR1C1 = "=OFFSET(RC14,0,RC[8],1,1)"
Range("E8").Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 184
Default Random Sorting

random*random

oops! pls use rand()^rand() instead
  #4   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Random Sorting

Thank's guy's for the prompt replys,

I've solved my problem using sulprobil's function.

Many thank's once again for your help.

------------------------------------------------------------------------
"Megaman" wrote in message
...
Can anyone help?

I have a sheet with the following data:

Item, Price1, Price2, Price3, Price4,


I want to sort the prices for each item randomly but not sorting the whole
col together but sorting row for row eg.

Item, Price3, Price2, Price4, Price1,

Item, Price2, Price4, Price3, Price1,

Item, Price1, Price2, Price3, Price4,

And so on down the rows.

I can sort the whole col. by using a rnd. number but that wont help as my
prices are from low to high and I need them to be scattered but still
relating
to the correct items.

Many thanks in advance,

Des



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
Random sorting with restrictions Blue Max Excel Worksheet Functions 2 March 19th 09 11:58 PM
Sorting random Data created from a random formula Six Sigma Blackbelt Excel Discussion (Misc queries) 1 September 11th 08 11:03 PM
Random sorting of list Kathrine Excel Discussion (Misc queries) 2 March 30th 07 11:12 AM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Excel random sorting query fingers Excel Programming 10 January 2nd 04 01:01 AM


All times are GMT +1. The time now is 01:21 AM.

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"