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
|