Randomize the lines

Discussion in 'Microsoft Word New Users' started by Wous Mant, Jun 14, 2004.

  1. Wous Mant

    Wous Mant Guest

    Hello,
    I'd like to randomize my lines in my text.
    For example my text is like this;

    America
    England
    Greece
    Malta
    Nigeria
    Yugoslavia

    I'd like it to be mixed/shuffled/randomized like this;

    Malta
    Yugoslavia
    England
    Nigeria
    America
    Greece

    Sort option only sorts in ascending or descending.Is there any way to
    do it in word ? or is there any tool which can do it?
    Thank you
     
    Wous Mant, Jun 14, 2004
    #1
    1. Advertisements

  2. Wous Mant

    Jay Freedman Guest

    Wous Mant wrote:
    > Hello,
    > I'd like to randomize my lines in my text.
    > For example my text is like this;
    >
    > America
    > England
    > Greece
    > Malta
    > Nigeria
    > Yugoslavia
    >
    > I'd like it to be mixed/shuffled/randomized like this;
    >
    > Malta
    > Yugoslavia
    > England
    > Nigeria
    > America
    > Greece
    >
    > Sort option only sorts in ascending or descending.Is there any way to
    > do it in word ? or is there any tool which can do it?
    > Thank you


    Use a macro like this one. It converts the selected text (or the whole
    document, if nothing is selected) to a table, adds a column, populates the
    new column with random numbers, sorts the table so the numbers are in order
    (which scrambles the paragraphs), and converts the table back to text.

    Sub Scramble()
    Dim oTbl As Table
    Dim nRow As Integer, maxRow As Integer

    Application.ScreenUpdating = False

    If (Selection.Type <> wdSelectionNormal) _
    Or (Selection.Paragraphs.Count < 2) Then
    ActiveDocument.Range.Select
    End If

    Set oTbl = Selection.ConvertToTable(Separator:=vbCr)
    With oTbl
    maxRow = .Rows.Count
    .Columns.Add beforecolumn:=.Columns(1)

    For nRow = 1 To maxRow
    .Cell(nRow, 1).Range.Text = _
    CInt(Rnd() * 10 * maxRow)
    Next nRow

    .Sort excludeheader:=False, _
    fieldnumber:=1, _
    sortfieldtype:=wdSortFieldNumeric, _
    sortorder:=wdSortOrderAscending

    .Columns(1).Delete
    .ConvertToText Separator:=vbCr
    End With

    Application.ScreenUpdating = True
    End Sub

    --
    Regards,
    Jay Freedman
    Microsoft Word MVP FAQ: http://word.mvps.org
     
    Jay Freedman, Jun 14, 2004
    #2
    1. Advertisements

  3. Wous Mant

    Wous Mant Guest

    I can not manage it to work :-<
    Is the macro only way?
     
    Wous Mant, Jun 15, 2004
    #3
  4. Wous Mant

    Jay Freedman Guest

    Wous Mant wrote:
    > I can not manage it to work :-<
    > Is the macro only way?


    Except for manually dragging the items from one place to another so they
    look random, a macro is the only way Word can do it.

    Have a look at this page, you may get it to work --
    http://www.gmayor.com/installing_macro.htm

    --
    Regards,
    Jay Freedman
    Microsoft Word MVP FAQ: http://word.mvps.org
     
    Jay Freedman, Jun 15, 2004
    #4
  5. Wous Mant

    Wous Mant Guest

    Thank you Jay Freedman
    Macro worked perfectly. It randomizes now how I want.
    Regards
     
    Wous Mant, Jun 16, 2004
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bill Anselm

    How to sort lines?

    Bill Anselm, Jul 23, 2003, in forum: Microsoft Word New Users
    Replies:
    1
    Views:
    725
    Suzanne S. Barnhill
    Jul 24, 2003
  2. Carol Whitney

    short lines in quoted email message text

    Carol Whitney, Sep 2, 2003, in forum: Microsoft Word New Users
    Replies:
    1
    Views:
    281
    Suzanne S. Barnhill
    Sep 2, 2003
  3. Tic

    lines shifted further to the right

    Tic, Sep 17, 2003, in forum: Microsoft Word New Users
    Replies:
    3
    Views:
    185
    Roxie Aho
    Sep 17, 2003
  4. Thomas McGregor
    Replies:
    2
    Views:
    501
    ANONYMOUS
    Apr 13, 2006
  5. Guest

    Is it possible to randomize data in a list

    Guest, Oct 28, 2006, in forum: Microsoft Word New Users
    Replies:
    2
    Views:
    155
    Guest
    Oct 30, 2006
Loading...

Share This Page