Sorting by Headings
Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Sorting by Headings.
A useful trick you can use when developing some types of documents is the ability to sort the various parts of the document based on the headings you use. For instance, you can sort the document based on first-level headings (paragraphs that use the Heading 1 style) by following these steps:
- Switch to Outline view by clicking on the Outline view button that appears just to the left of the horizontal scroll bar.
- Using the controls on the Outlining toolbar, collapse the headings so that only the first-level headings are shown. (This step is not strictly necessary, but does make the screen a bit more readable.)
- Place the cursor at the beginning of the first heading and press Ctrl+Shift+End to select everything through the end of the document.
- Choose Sort from the Table menu. Word displays the Sort Text dialog box. (See Figure 1.)
Figure 1. The Sort Text dialog box.
- Click on OK to accept the default settings in the dialog box.
Had you skipped the first two steps and performed the sort in any view besides Outline view, every paragraph would have been sorted alphabetically and therefore rearranged so that subordinate paragraphs would be separated from their headings. In other words, you would have a mess. However, in Outline view, the highest-level headings are sorted, bringing along the subordinate heading levels and body text.
If you wanted to sort by Heading 2 paragraphs, you should also use Outline view, but you would have to first select all the Heading 2 paragraphs subordinate to a particular Heading 1 paragraph and then sort. You will get the same results regardless of how many heading levels that you show on the Outline toolbar.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (41) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Sorting by Headings.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Leave your own comment:
Comments for this tip:
Silver Doll 24 Sep 2015, 09:31
Beautiful. That's an useful tip.
Su 12 May 2015, 23:19
Thank you very much. This made my recipes so much more easy to find in the table of contents!
SDavis 26 Dec 2014, 22:03
Thanks so much for your help!
Pali 11 Aug 2014, 04:25
thanks for helpful tip, it saved me a lot of work! great!
Terry 08 Jul 2014, 12:10
Excellent! Only had one problem and that is my index got sorted in the mix. I just deleted it and reinserted it. I needed my Table of Contents in alpha order because it is a click through and this solved that problem. I did the sort then updated my Table of Contents and all is good. Thank you!!
Buble Gum 03 Jan 2014, 19:11
Thank you for the tip. I was helpful, indeed.
Sandra 08 Jul 2013, 07:47
Hi, I'm not sure if this will work for my problem.
I have 248 songs (one per page) in a word document.
I need to sort them alphabetically.
Any tips! Help!
Happy User 07 Jun 2013, 03:00
Fantastic Tip.. Thanks from Australia..!!!
Joe 23 May 2013, 07:35
Great tip on sorting in word outline. I didn't know this was even possible. Thank you very for this tip.
Jeff 15 Mar 2013, 15:43
Ok, there is a problem but I found the workaround. The problem is that I had a table of contents which Word 2010 considers a "field"
Even though that table of contents was not in the selection, word still couldn't sort it. Once I removed the table of contents, I could sort. Then, I reinserted the table of contents again.
Strange that Word's error message was cryptic and wrong ... table of contents is not what most people call a field but ... worse ... it wasn't in the selection!
mr 11 Mar 2013, 06:13
thanks a lot!
awyatt 16 Jan 2013, 10:23
There was no table menu option available because you are using Word 2007 or Word 2010, and this tip is for older versions of Word. (The give-away was that you mentioned the Home tab, which is only available in Word 2007 and Word 2010.)
To see the steps that *will* work for you, click the link at the end of the tip to see the steps that will work in later versions of Word.
Eileen 16 Jan 2013, 10:18
There was no table menu option available for me. I got it to work by doing the following:
-Put a pipe character (|) at the end of each page before a new heading. (You can use any character that doesn't occur in your document.)
-Follow the procedure above up to #4.
-Go to the Home tab and click on the Sort Ascending key.
-Set the conditions so that the pipe character is the sort key (Options button in the Sort Text dialog box); set the "Sort by" to Field 1.
-Click ok and it should sort correctly.
-Remove the pipe characters using Find and Replace.
voja 02 Sep 2012, 04:15
I just have tried your recipe and it works brilliantly in Preview Word 2013. You saved me of tedious job of arranging over 900 pages. In a sec. I could not believe. Checked it over again, great relief. Very best regards, and thank you, again.
Analytical Guy 08 Jul 2012, 16:25
This worked. Thanks.
My experience was that it didn't work until I collapsed all the text underneath my H2 headings, but then it worked fine.