Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
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
Randomize from a list PEGWINN Excel Discussion (Misc queries) 12 August 4th 09 11:59 AM
randomize a list LelandKramer Excel Discussion (Misc queries) 1 July 13th 09 09:29 PM
How can I randomize a set of data? Hannie1004 Excel Worksheet Functions 1 February 14th 06 10:06 PM
Randomize rows Robb Quirk Excel Worksheet Functions 4 February 3rd 06 11:28 AM
How do I randomize words within a row? K8 Excel Discussion (Misc queries) 2 May 25th 05 09:22 PM


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