Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 47
Default Randomize cells in single column

Please excuse the duplicate posting.
I need a VBA code that will randomly sort all selected cells in a 'Single'
column (E). In the previous posting yesterday I was given a code that would
random sort but only in 'Multiple' columns and I can't figure out how to get
it to work on just a single column. Can someone please help this amateur?
Again, please excuse the duplicate posting.

Thanks,
Guy
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Randomize cells in single column

Hi,

With apologies to the original author (Who I can't remember) right click
your sheet tab, view code and paste this in. Select your data and run the code

Sub MixEmUp()
Dim T As Variant
Dim MyArray As Variant
Dim rng As Range
Dim i As Integer, i1 As Integer
Dim j As Integer, j1 As Integer
Set rng = Selection
MyArray = rng.Value
For i = UBound(MyArray, 1) To 1& Step -1&
For j = UBound(MyArray, 2) To 1& Step -1&
i1 = Int(Rnd() * i) + 1&
j1 = Int(Rnd() * j) + 1&
T = MyArray(i, j)
MyArray(i, j) = MyArray(i1, j1)
MyArray(i1, j1) = T
Next j
Next i
rng.Value = MyArray
End Sub

Mike

"Guy" wrote:

Please excuse the duplicate posting.
I need a VBA code that will randomly sort all selected cells in a 'Single'
column (E). In the previous posting yesterday I was given a code that would
random sort but only in 'Multiple' columns and I can't figure out how to get
it to work on just a single column. Can someone please help this amateur?
Again, please excuse the duplicate posting.

Thanks,
Guy

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 47
Default Randomize cells in single column

Perfect!!!
Thanks a bunch!
Guy

"Mike H" wrote:

Hi,

With apologies to the original author (Who I can't remember) right click
your sheet tab, view code and paste this in. Select your data and run the code

Sub MixEmUp()
Dim T As Variant
Dim MyArray As Variant
Dim rng As Range
Dim i As Integer, i1 As Integer
Dim j As Integer, j1 As Integer
Set rng = Selection
MyArray = rng.Value
For i = UBound(MyArray, 1) To 1& Step -1&
For j = UBound(MyArray, 2) To 1& Step -1&
i1 = Int(Rnd() * i) + 1&
j1 = Int(Rnd() * j) + 1&
T = MyArray(i, j)
MyArray(i, j) = MyArray(i1, j1)
MyArray(i1, j1) = T
Next j
Next i
rng.Value = MyArray
End Sub

Mike

"Guy" wrote:

Please excuse the duplicate posting.
I need a VBA code that will randomly sort all selected cells in a 'Single'
column (E). In the previous posting yesterday I was given a code that would
random sort but only in 'Multiple' columns and I can't figure out how to get
it to work on just a single column. Can someone please help this amateur?
Again, please excuse the duplicate posting.

Thanks,
Guy

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 a set of numbers in 1 column that are located in another Six Sigma Blackbelt Excel Worksheet Functions 5 September 4th 08 07:54 PM
Can I randomize numbers ALREADY in a column? GrsmRngr Excel Worksheet Functions 2 March 13th 08 01:16 PM
Copying a column of single cells into a column of merged cells [email protected] Excel Discussion (Misc queries) 1 August 16th 06 01:18 PM
Copy column range of "single word" cells with spaces to a single c nastech Excel Discussion (Misc queries) 3 February 15th 06 05:04 PM
I need to randomize a column of alphanumeric employee ID's for a . topkick Excel Worksheet Functions 9 November 9th 04 02:38 PM


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