+ Reply to Thread
Results 1 to 10 of 10

Randomly shuffle columns

Hybrid View

Savan87 Randomly shuffle columns 06-10-2011, 08:55 AM
Domski Re: Randomly shuffle columns 06-10-2011, 09:13 AM
Savan87 Re: Randomly shuffle columns 06-10-2011, 09:19 AM
Domski Re: Randomly shuffle columns 06-10-2011, 09:24 AM
Savan87 Re: Randomly shuffle columns 06-10-2011, 09:29 AM
ChemistB Re: Randomly shuffle columns 06-10-2011, 09:26 AM
Savan87 Re: Randomly shuffle columns 06-10-2011, 10:50 AM
  1. #1
    Registered User
    Join Date
    02-01-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    33

    Randomly shuffle columns

    I have 1000 columns which I would like to individually shuffle one by one, is anyone aware of a VBA script that would allow me to do so without repeatedly using =Rand() and then manually sorting by it.

    Regards
    Last edited by Savan87; 06-10-2011 at 10:49 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Randomly shuffle columns

    Maybe:

    Sub test()
    
    Rows(1).Insert
    Range("A1").Resize(1, Cells(2, Columns.Count).End(xlToLeft).Column).Formula = "=RAND()"
    Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo, _
            OrderCustom:=1, Orientation:=xlLeftToRight
    Rows(1).Delete
    
    End Sub

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    02-01-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Randomly shuffle columns

    I dont believe that resolves what I'm trying to achieve,

    I want each column to be shuffled randomly so that the order of the values changes but the overall properties of that column stay the same average, range, min, max etc.

    I believe that code you posted, changes the columns properties

    Thanks very much for your quick reply

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Randomly shuffle columns

    I'm not sure I follow, could you post an example workbook with the formula that you think are effected?

    Dom

  5. #5
    Registered User
    Join Date
    02-01-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Randomly shuffle columns

    Basically what I want to do is randomly shuffle the values in column A so they are in a new order, I then want to shuffle B so that the values are in a new order and so on

    Thanks alot
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-01-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Randomly shuffle columns

    I want each column to be independent from the one next to it

    Thanks

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Randomly shuffle columns

    Do you want to shuffle by rows or have each column independent of the one next to it?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  8. #8
    Registered User
    Join Date
    02-01-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Randomly shuffle columns

    Ty for your assistance once again

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1