ordering list by last name?

I

ianbooks

Hello--

I'm a newbie to the group & somewhat to MS Word. Is there a simple way
to highlight a list of names and sort it by the second word (i.e. the
last name)? I've only found a sort function that works on the first
word in each item.

TIA,

Ian
 
B

Barry Wainwright [MVP]

Hello--

I'm a newbie to the group & somewhat to MS Word. Is there a simple way
to highlight a list of names and sort it by the second word (i.e. the
last name)? I've only found a sort function that works on the first
word in each item.

TIA,

Ian

Not in word there isn't :(
 
B

Barry Wainwright [MVP]

Not in word there isn't :(

Maybe I spoke too quickly...

1. Select the list of names
2. choose 'Convert > Text to table' from the Table menu. In the 'separate
at' part of the dialog, choose 'other' and type a space into the character
box
3. choose 'sort' from the Table menu and select 'column 2'
4. select the sorted table
5. choose 'convert > table to text' from the table menu. Use 'other' again
and type a space in the character box.

Bingo :)

Here's a macro that will sort a series of selected paragraphs by the second
word:

Sub second_name_sort()
Selection.ConvertToTable Separator:=" "
Selection.Sort FieldNumber:="Column 2",
SortFieldType:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending
Selection.Rows.ConvertToText Separator:=" "
End Sub
 
D

Daiya Mitchell

Barry's solution will work fine, but an alternate approach‹

The text does not need to be in a table to sort on Word 2. Select your
text, use Table | Sort, and change the "sort by" setting from Paragraphs to
Word 2 (or word 3, or word 4). Works fine here.

Middle initials will mess you up, though.
 
B

Barry Wainwright [MVP]

Well, what do you know!

I couldn't get 'words' to show up when I first looked at that, it just
showed 'Paragraphs' and 'field 1'. I just went back to try again, and the
'words' only show up when you choose the 'Options...' and set the delimiter
to a space.

Hmmm - my first public VB script, and its not needed! Ah, well <g>
 
D

Daiya Mitchell

Ah, thanks, Barry, for that missing step.

I wonder--no time to test now--Word might be smart enough to actually change
the options according to preselected text. Because my Options are now set
to a tab. Also, it doesn't offer "word 4" as a sorting option unless there
are actually lines with 4 words.
 
B

Barry Wainwright [MVP]

I wonder--no time to test now--Word might be smart enough to actually change
the options according to preselected text.

Yes, it does appear to.
 
C

Clive Huggan

If the first name + last occupies sufficiently common territory that you
could select an area in each second name only a millimetre wide (but
encompassing parts of all second names in its vertical extent) you could do
that -- hold down the Option key and drag to select part of each second word
-- then Sort. If not all were encompassed by this, a little manual amendment
might be needed.

If there are only first names and last names in the list, i.e. no other
words, you could do a Replace All [replace all spaces with tabs]. Then hold
down the Option key and drag to select part of each second word. Then Sort.

If there are more than just first names and last names in the list, you
would need to replace with tabs manually (but changing back would be done by
a Change All).

Cheers,

Clive Huggan
Canberra, Australia
(My time zone is 5-11 hours different from the US and Europe, so my
follow-on responses to those regions can be delayed)
============================================================
* SUGGESTION -- KEEP REVISITING AFTER YOU POST: If you post a question, keep
re-visiting the newsgroup for several days after the first response comes
in. Sometimes it takes a few responses before the best or complete solution
is provided; sometimes you'll be asked for further information. Good tips
about getting the best out of posting are at
http://word.mvps.org/Mac/AccessNewsgroups.html and
http://word.mvps.org/FindHelp/Posting.htm (if you use Safari you may see a
blank page and have to hit the circular arrow icon -- "Reload the current
page" -- two or more times).
============================================================
 
C

CyberTaz

It doesn't appear to identify the *2* field initially because the default
separator is <Tab>. However, once you go to Options & select <Space> as the
separator, exit both dialogs & go into Sort again it will give you Word 1 &
Word 2 in the Sort By list. OTOH, if the text is separated by tabs the
appropriate number of choices will be in the list the first time. Also, once
you set the Separator to something other than <Tab> it appears to hold the
new setting as the default. Seems to work the same way in 2003 & 2004.

Regards |:>)
Bob Jones
[MVP] Office:Mac
 
J

John McGhie [MVP - Word and Word Macintosh]

It also fails to correctly identify the fields if the first row is the first
paragraph in the document, or if the first word of any row contains what
Word thinks is a spelling error :) These would be "bugs" :)

You can deal with middle initials and such by delimiting them with
non-breaking spaces.

If you set a Space as your delimiter in Options, Word will process
non-breaking spaces as text characters, not as delimiters.

Cheers


It doesn't appear to identify the *2* field initially because the default
separator is <Tab>. However, once you go to Options & select <Space> as the
separator, exit both dialogs & go into Sort again it will give you Word 1 &
Word 2 in the Sort By list. OTOH, if the text is separated by tabs the
appropriate number of choices will be in the list the first time. Also, once
you set the Separator to something other than <Tab> it appears to hold the
new setting as the default. Seems to work the same way in 2003 & 2004.

Regards |:>)
Bob Jones
[MVP] Office:Mac

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Business Analyst, Consultant
Technical Writer.
Sydney, Australia +61 (0) 4 1209 1410
 
L

little_creature

What I would do is to use table where 1 row will be the name and second
surname and then use table>sort according to 2 row. I'm currently on PC
so I cannot verify it, so can you do that? If you do not want to see the
borders of table then set the border to line to none. This will cause
that the table will be invisible and enable you sorting.
If you have any problem, post back.

ianbooks said the following on 13.10.2006 15:50:
 
J

John McGhie [MVP - Word and Word Macintosh]

Yes, you are correct. He *can* use a table for this job. However, if his
existing list is NOT currently in a table, it will be easier to simply sort
it as paragraphs.

I would probably use a table unless I was completely sure of the state of
the input list. In a table, it's easy to see and deal with problems in the
input list.

What I would do is to use table where 1 row will be the name and second
surname and then use table>sort according to 2 row. I'm currently on PC
so I cannot verify it, so can you do that? If you do not want to see the
borders of table then set the border to line to none. This will cause
that the table will be invisible and enable you sorting.
If you have any problem, post back.

ianbooks said the following on 13.10.2006 15:50:

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Business Analyst, Consultant
Technical Writer.
Sydney, Australia +61 (0) 4 1209 1410
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top