Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to randomize a range
I have a set of numbers in cells (a1:a20) that I would
like to have resorted in random order each time I open the workbook. I have searched the newsgroups for excel and I cannot find one. Any help would be appreciated Thanks David |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to randomize a range
Private Sub Workbook_Open()
With ThisWorkbook.Worksheets("Sheet1") .Columns(2).Insert .Range("B1:B20").Formula = "=rand()" .Range("A1:B20").Sort Key1:=.Range("B1"), _ Order1:=xlAscending .Columns(2).Delete End With End Sub go to the vbe and in the project explorer (treeview) select your project/workbook. Double click on the thisWorkbook entry in the treeview for your project. Paste in the above code. If there is an additional declaration Private sub Workbook_Open() End sub then delete that. Save the workbook. -- Regards, Tom Ogilvy david wright wrote in message ... I have a set of numbers in cells (a1:a20) that I would like to have resorted in random order each time I open the workbook. I have searched the newsgroups for excel and I cannot find one. Any help would be appreciated Thanks David |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to randomize a range
Tom,
Thank You Very Much DW -----Original Message----- Private Sub Workbook_Open() With ThisWorkbook.Worksheets("Sheet1") .Columns(2).Insert .Range("B1:B20").Formula = "=rand()" .Range("A1:B20").Sort Key1:=.Range("B1"), _ Order1:=xlAscending .Columns(2).Delete End With End Sub go to the vbe and in the project explorer (treeview) select your project/workbook. Double click on the thisWorkbook entry in the treeview for your project. Paste in the above code. If there is an additional declaration Private sub Workbook_Open() End sub then delete that. Save the workbook. -- Regards, Tom Ogilvy david wright wrote in message ... I have a set of numbers in cells (a1:a20) that I would like to have resorted in random order each time I open the workbook. I have searched the newsgroups for excel and I cannot find one. Any help would be appreciated Thanks David . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Randomize from a list | Excel Discussion (Misc queries) | |||
randomize a list | Excel Discussion (Misc queries) | |||
How can I randomize a set of data? | Excel Worksheet Functions | |||
Randomize rows | Excel Worksheet Functions | |||
How do I randomize words within a row? | Excel Discussion (Misc queries) |