PC Review


Reply
Thread Tools Rate Thread

Randomize the lines

 
 
Wous Mant
Guest
Posts: n/a
 
      14th Jun 2004
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
 
Reply With Quote
 
 
 
 
Jay Freedman
Guest
Posts: n/a
 
      14th Jun 2004
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


 
Reply With Quote
 
 
 
 
Wous Mant
Guest
Posts: n/a
 
      15th Jun 2004
I can not manage it to work :-<
Is the macro only way?
 
Reply With Quote
 
Jay Freedman
Guest
Posts: n/a
 
      15th Jun 2004
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


 
Reply With Quote
 
Wous Mant
Guest
Posts: n/a
 
      16th Jun 2004
Thank you Jay Freedman
Macro worked perfectly. It randomizes now how I want.
Regards
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I Remove lines above a key word, remove the lines below another, and keep the lines between the to key words in a Text File? Quentin Microsoft VB .NET 2 20th Apr 2007 07:34 PM
Randomize popups =?Utf-8?B?ZnJlZEBDRGlnT20uY29t?= Windows XP Internet Explorer 4 16th Apr 2005 12:08 AM
Randomize slides =?Utf-8?B?SXJpc2gtd29tYW4=?= Microsoft Powerpoint 9 25th Jun 2004 11:54 PM
How do I randomize my slides =?Utf-8?B?U3VzYW4=?= Microsoft Powerpoint 2 16th Mar 2004 11:53 PM
Re: Embed AND randomize WAV files B Microsoft Powerpoint 2 21st Jul 2003 05:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:31 PM.