Working with Lists

In my other life I work at a publishing house, so quite often I compile and edit lists of book titles, authors, type specs--all kinds of things. (I just finished putting together a list of nearly 1,400 book titles for a giant electronic publishing project.) A typical list looks like this:

To Kill a Mockingbird

Jane Eyre

Old Man and the Sea

Great Gatsby

Moby Dick

And so on. (You'll notice that I removed the initial "The" from The Old Man and the Sea and The Great Gatsby so they'll sort properly. You may also want to do this with "A" and "An" if you're sorting lists of books.)

BMW (before Microsoft Word) I used to sort such lists by hand. Now I sort them like this:

1. In Microsoft Word, select the paragraphs making up the list to be sorted.

2. Click the Table menu.

3. Click "Sort" or "Sort Text."

4. Under "Sort by," select "Paragraphs."

5. Under "Type," select "Text."

6. Select "Ascending."

7. Click "OK."

Wow, that works great! But wait a minute. I've got Great Gatsby in here three times! And Moby Dick twice! I wonder how many other duplicates I've got. Isn't there a way to delete them automatically?

In fact, there is. Just use this trusty macro, compliments of the Editorium:

FOR MICROSOFT WORD 6 OR 7 (95):

'THE MACRO STARTS HERE
StartOfDocument
ParaDown 1, 1
Para1$ = Selection$()
CharRight 1
While AtEndOfDocument() = 0
ParaDown 1, 1
Para2$ = Selection$()
If Para1$ = Para2$ Then
WW6_EditClear
Else
Para1$ = Para2$
CharRight 1
EndIf
Wend
'THE MACRO ENDS HERE


FOR MICROSOFT WORD 8 (97 OR 98) OR 9 (2000):

'THE MACRO STARTS HERE
Dim Para1$
Dim Para2$
WordBasic.StartOfDocument
WordBasic.ParaDown 1, 1
Para1$ = WordBasic.[Selection$]()
WordBasic.CharRight 1
While WordBasic.AtEndOfDocument() = 0
WordBasic.ParaDown 1, 1
Para2$ = WordBasic.[Selection$]()
If Para1$ = Para2$ Then
WordBasic.WW6_EditClear
Else
Para1$ = Para2$
WordBasic.CharRight 1
End If
Wend
'THE MACRO ENDS HERE

TO CREATE THE MACRO

1. Copy the appropriate macro from this newsletter.

2. Click the "Tools" menu at the top of your Word window.

3. Click "Macro."

4. In Word 97, 98, or 2000, click "Macros."

5. Make sure "Macros Available In" shows "Normal.dot."

6. Type a name for the macro in the "Macro Name" box--"DeleteDuplicates" should do nicely.

7. Click "Create."

8. Paste the macro at the current insertion point.

9. In Word 6 or 7, click "File," then "Close," then "Yes." In Word 97, 98, or 2000, click "File," then "Close and Return to Microsoft Word."

TO RUN THE MACRO:

1. *Back up your document* in case something doesn't work quite right.

2. Click the "Tools" menu at the top of your Word window.

3. Click "Macro."

4. In Word 97, 98, or 2000, click "Macros."

5. Make sure "Macros Available In" shows "Normal.dot."

6. Select the macro (probably "DeleteDuplicates") in the "Macro Name" box.

7. Click "Run."

No more duplicates! (If you still see what seem to be duplicates, check them carefully. One of the pair may be spelled slightly differently or have an invisible space preceding the carriage return.)

If you need other macros to make your life easier, you may be interested in our program add-ins at http://www.editorium.com. If you're editing, writing, or typesetting in Microsoft Word, they'll save you time. Couldn't you use more of it?

This entry was posted in Editing. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

You must be logged in to post a comment.

  • The Fine Print

    Thanks for reading Editorium Update (ISSN 1534-1283), published by:

    The EDITORIUM, LLC
    http://www.editorium.com

    Articles © on date of publication by the Editorium. All rights reserved. Editorium Update and Editorium are trademarks of the Editorium.

    You may forward copies of Editorium Update to others (but not charge for it) and print or store it for your personal use. Any other broadcast, publication, retransmission, copying, or storage, without written permission from the Editorium, is strictly prohibited. If you’re interested in reprinting one of our articles, please send an email message to editor@editorium.com

    Editorium Update is provided for informational purposes only and without a warranty of any kind, either express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. The user (you) assumes the entire risk as to the accuracy and use of this document.

    The Editorium is not affiliated with Microsoft Corporation or any other entity.

    We do not sell, rent, or give our subscriber list to anyone. Period.

    If you’d like to subscribe, please enter your name and email address below. We publish the newsletter once a week, and on rare occasions we may send an important announcement. We never, ever send spam. Thank you for signing up!