Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
u50st u50st is offline
external usenet poster
 
Posts: 2
Default Word Sorting

I swear I used to be able to sort a list of first and last names by the last
name, however I can't figure out how I did it. I am using Word 2003.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

If they're in the form

Roe, Richard
Doe, John

(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).

If they're in the form

Richard Roe
John Doe

then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

On Jan 14, 1:51*pm, u50st wrote:
I swear I used to be able to sort a list of first and last names by the last
name, however I can't figure out how I did it. I am using Word 2003.


  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

If they're in the form

Roe, Richard
Doe, John

(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).

If they're in the form

Richard Roe
John Doe

then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

On Jan 14, 1:51*pm, u50st wrote:
I swear I used to be able to sort a list of first and last names by the last
name, however I can't figure out how I did it. I am using Word 2003.


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

Actually, you don't have to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
If they're in the form

Roe, Richard
Doe, John

(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).

If they're in the form

Richard Roe
John Doe

then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

On Jan 14, 1:51 pm, u50st wrote:
I swear I used to be able to sort a list of first and last names by the
last
name, however I can't figure out how I did it. I am using Word 2003.


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

Actually, you don't have to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
If they're in the form

Roe, Richard
Doe, John

(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).

If they're in the form

Richard Roe
John Doe

then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

On Jan 14, 1:51 pm, u50st wrote:
I swear I used to be able to sort a list of first and last names by the
last
name, however I can't figure out how I did it. I am using Word 2003.




  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

Wow. As someone said yesterday, Is that documented anywhere?

On Jan 14, 5:10*pm, "Suzanne S. Barnhill" wrote:
Actually, you don't have to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
If they're in the form

Roe, Richard
Doe, John

(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).

If they're in the form

Richard Roe
John Doe

then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

On Jan 14, 1:51 pm, u50st wrote:



I swear I used to be able to sort a list of first and last names by the
last
name, however I can't figure out how I did it. I am using Word 2003.-

  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

Wow. As someone said yesterday, Is that documented anywhere?

On Jan 14, 5:10*pm, "Suzanne S. Barnhill" wrote:
Actually, you don't have to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
If they're in the form

Roe, Richard
Doe, John

(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).

If they're in the form

Richard Roe
John Doe

then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

On Jan 14, 1:51 pm, u50st wrote:



I swear I used to be able to sort a list of first and last names by the
last
name, however I can't figure out how I did it. I am using Word 2003.-

  #8   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

Word 2003's Help topic "About sorting" contains this intriguing paragraph:

"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."

There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:

"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don't want to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2 (or
the field you want to sort by), and then complete the sort as usual."

So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells you
how to do it right in the first place--an odd approach to take IMO).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
Wow. As someone said yesterday, Is that documented anywhere?

On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:
Actually, you don't have to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
If they're in the form

Roe, Richard
Doe, John

(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).

If they're in the form

Richard Roe
John Doe

then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

On Jan 14, 1:51 pm, u50st wrote:



I swear I used to be able to sort a list of first and last names by the
last
name, however I can't figure out how I did it. I am using Word 2003.-


  #9   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

Word 2003's Help topic "About sorting" contains this intriguing paragraph:

"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."

There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:

"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don't want to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2 (or
the field you want to sort by), and then complete the sort as usual."

So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells you
how to do it right in the first place--an odd approach to take IMO).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
Wow. As someone said yesterday, Is that documented anywhere?

On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:
Actually, you don't have to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
If they're in the form

Roe, Richard
Doe, John

(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).

If they're in the form

Richard Roe
John Doe

then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

On Jan 14, 1:51 pm, u50st wrote:



I swear I used to be able to sort a list of first and last names by the
last
name, however I can't figure out how I did it. I am using Word 2003.-


  #10   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

Help is so helpful!

Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.

On Jan 14, 11:05*pm, "Suzanne S. Barnhill" wrote:
Word 2003's Help topic "About sorting" contains this intriguing paragraph:

"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."

There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:

"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don't want to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2 (or
the field you want to sort by), and then complete the sort as usual."

So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells you
how to do it right in the first place--an odd approach to take IMO).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
Wow. As someone said yesterday, Is that documented anywhere?

On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:



Actually, you don't have to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names by the
last
name, however I can't figure out how I did it. I am using Word 2003.--



  #11   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

Help is so helpful!

Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.

On Jan 14, 11:05*pm, "Suzanne S. Barnhill" wrote:
Word 2003's Help topic "About sorting" contains this intriguing paragraph:

"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."

There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:

"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don't want to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2 (or
the field you want to sort by), and then complete the sort as usual."

So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells you
how to do it right in the first place--an odd approach to take IMO).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
Wow. As someone said yesterday, Is that documented anywhere?

On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:



Actually, you don't have to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names by the
last
name, however I can't figure out how I did it. I am using Word 2003.--

  #12   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

Perhaps. I've never had a list long enough to require this; I just run
through it manually (F4 is helpful).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
Help is so helpful!

Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.

On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:
Word 2003's Help topic "About sorting" contains this intriguing paragraph:

"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you
can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."

There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:

"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don't want to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table
menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2
(or
the field you want to sort by), and then complete the sort as usual."

So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells
you
how to do it right in the first place--an odd approach to take IMO).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?

On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:



Actually, you don't have to convert to a table to sort the second list.
In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names by
the
last
name, however I can't figure out how I did it. I am using Word 2003.--


  #13   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

Perhaps. I've never had a list long enough to require this; I just run
through it manually (F4 is helpful).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
Help is so helpful!

Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.

On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:
Word 2003's Help topic "About sorting" contains this intriguing paragraph:

"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you
can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."

There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:

"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don't want to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table
menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2
(or
the field you want to sort by), and then complete the sort as usual."

So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells
you
how to do it right in the first place--an odd approach to take IMO).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?

On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:



Actually, you don't have to convert to a table to sort the second list.
In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "Peter T." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don't have to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names by
the
last
name, however I can't figure out how I did it. I am using Word 2003.--


  #14   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 264
Default Word Sorting


The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub



On Jan 15, 6:56*am, "Peter T. Daniels" wrote:
Help is so helpful!

Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.

On Jan 14, 11:05*pm, "Suzanne S. Barnhill" wrote:



Word 2003's Help topic "About sorting" contains this intriguing paragraph:


"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2 (or
the field you want to sort by), and then complete the sort as usual."


So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in ...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second list.. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text..


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names by the
last
name, however I can'tfigure out how I did it. I am using Word 2003.--- Hide quoted text -


- Show quoted text -


  #15   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 264
Default Word Sorting


The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub



On Jan 15, 6:56*am, "Peter T. Daniels" wrote:
Help is so helpful!

Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.

On Jan 14, 11:05*pm, "Suzanne S. Barnhill" wrote:



Word 2003's Help topic "About sorting" contains this intriguing paragraph:


"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2 (or
the field you want to sort by), and then complete the sort as usual."


So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in ...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second list.. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text..


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names by the
last
name, however I can'tfigure out how I did it. I am using Word 2003.--- Hide quoted text -


- Show quoted text -




  #16   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55*pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. *Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. *Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. *Applebee
Joe A. Miller, III
A. A. *Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
* *MsgBox "There is no valid selection to sort"
* *Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
* bEndofDoc = True
* oRngSelected.InsertAfter vbCr
* oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
* Set oRng = oPar.Range
* If InStr(oPar.Range.Text, ",") 0 Then
* * oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
* * oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
* * oRng.Words(oRng.Words.Count).Delete
* Else
* * oRng.End = oRng.End - 1
* * oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
* * oRng.Words(oRng.Words.Count).Delete
* End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
* SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
* FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
* wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
* wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
* wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
* :=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
* bEndofDoc = True
* oRngSelected.InsertAfter vbCr
* oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
* Set oRng = oPar.Range
* With oRng
* * pStr = " " & .Words.First.Text
* * .Collapse wdCollapseStart
* * .End = .Words.First.End + 2
* * .Delete
* End With
* Set oRng = oPar.Range
* If InStr(oPar.Range.Text, ",") 0 Then
* * oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
* * oRng.InsertAfter pStr
* Else
* * oRng.End = oRng.End - 1
* * oRng.InsertAfter pStr
* End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
* For i = 0 To UBound(vOrigText)
* * Select Case bSet
* * *Case True
* * * *.Text = vOrigText(i)
* * * *.Replacement.Text = vFlagText(i)
* * *Case Else
* * * * .Text = vFlagText(i)
* * * *.Replacement.Text = vOrigText(i)
* * *End Select
* * .Execute Replace:=wdReplaceAll
* Next i
End With
End Sub

On Jan 15, 6:56*am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05*pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing paragraph:


"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2 (or
the field you want to sort by), and then complete the sort as usual."


So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in ...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

  #17   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55*pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. *Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. *Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. *Applebee
Joe A. Miller, III
A. A. *Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
* *MsgBox "There is no valid selection to sort"
* *Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
* bEndofDoc = True
* oRngSelected.InsertAfter vbCr
* oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
* Set oRng = oPar.Range
* If InStr(oPar.Range.Text, ",") 0 Then
* * oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
* * oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
* * oRng.Words(oRng.Words.Count).Delete
* Else
* * oRng.End = oRng.End - 1
* * oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
* * oRng.Words(oRng.Words.Count).Delete
* End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
* SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
* FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
* wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
* wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
* wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
* :=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
* bEndofDoc = True
* oRngSelected.InsertAfter vbCr
* oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
* Set oRng = oPar.Range
* With oRng
* * pStr = " " & .Words.First.Text
* * .Collapse wdCollapseStart
* * .End = .Words.First.End + 2
* * .Delete
* End With
* Set oRng = oPar.Range
* If InStr(oPar.Range.Text, ",") 0 Then
* * oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
* * oRng.InsertAfter pStr
* Else
* * oRng.End = oRng.End - 1
* * oRng.InsertAfter pStr
* End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
* For i = 0 To UBound(vOrigText)
* * Select Case bSet
* * *Case True
* * * *.Text = vOrigText(i)
* * * *.Replacement.Text = vFlagText(i)
* * *Case Else
* * * * .Text = vFlagText(i)
* * * *.Replacement.Text = vOrigText(i)
* * *End Select
* * .Execute Replace:=wdReplaceAll
* Next i
End With
End Sub

On Jan 15, 6:56*am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05*pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing paragraph:


"You can also sort by more than one word or field inside a single table
column. For example, if a column contains both last and first names, you can
sort by either last name or first name, just as you could if the last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what appears
to be a single table column. The "Troubleshoot sorting" entry dances all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column but
appears to say nothing about using any but the first word as the primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order by
using a combination of regular spaces and nonbreaking spaces. Type a regular
space between fields you want to sort on, and press CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on. For
example, type Dr.nonbreaking spaceJohn Smith or John Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table menu.
Click Options, and then click Other under Separate fields at. In the text
box, type a space, and then click OK. In the Sort by list, click Word 2 (or
the field you want to sort by), and then complete the sort as usual."


So yes, this is documented, but you have to wade through a lot of other
stuff to get to it (and you can find it only in an article that addresses
"things that go wrong when I'm sorting," not in one that actually tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in ...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second list. In
the Sort dialog, click on Options, choose Other, and type a space in the
box, then click OK. When you return to the Sort dialog, you should have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains the
name you want to alphabetize on (simple if every name has just a first
name and a last name!), sort on that column, and Convert back to Text.

  #18   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Word Sorting

Hmm yes. As I said, the complicatons breed like rabbits.

That now rather incomplete solution was scratched together some time ago and
yes to work as written "any" suffix needs to be preceeded by a comma. I see
and agree that Joe A. Miller III is the appropriate format as is Miller, Joe
A, III (correct?). When time allows I will see if I can work out some way
of dealing with that problem.



Peter T. Daniels wrote:
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill"
wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first
names, you can
sort by either last name or first name, just as you could if the
last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry
dances all
around this without spelling it out (it does mention the
nonbreaking
spaces); it describes sorting by more than one word in a given
column but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort
order by
using a combination of regular spaces and nonbreaking spaces. Type
a regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort
on. For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the
Table menu.
Click Options, and then click Other under Separate fields at. In
the text
box, type a space, and then click OK. In the Sort by list, click
Word 2 (or
the field you want to sort by), and then complete the sort as
usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses "things that go wrong when I'm sorting," not in one that
actually tells you
how to do it right in the first place--an odd approach to take
IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill"
wrote:


Actually, you don'thave to convert to a table to sort the second
list. In the Sort dialog, click on Options, choose Other, and
type a space in the box, then click OK. When you return to the
Sort dialog, you should have Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some
of the names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the
space in, say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column
contains the name you want to alphabetize on (simple if every
name has just a first name and a last name!), sort on that
column, and Convert back to Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the last
name, however I can'tfigure out how I did it. I am using Word
2003.---



  #19   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Word Sorting

Hmm yes. As I said, the complicatons breed like rabbits.

That now rather incomplete solution was scratched together some time ago and
yes to work as written "any" suffix needs to be preceeded by a comma. I see
and agree that Joe A. Miller III is the appropriate format as is Miller, Joe
A, III (correct?). When time allows I will see if I can work out some way
of dealing with that problem.



Peter T. Daniels wrote:
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill"
wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first
names, you can
sort by either last name or first name, just as you could if the
last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry
dances all
around this without spelling it out (it does mention the
nonbreaking
spaces); it describes sorting by more than one word in a given
column but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort
order by
using a combination of regular spaces and nonbreaking spaces. Type
a regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort
on. For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the
Table menu.
Click Options, and then click Other under Separate fields at. In
the text
box, type a space, and then click OK. In the Sort by list, click
Word 2 (or
the field you want to sort by), and then complete the sort as
usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses "things that go wrong when I'm sorting," not in one that
actually tells you
how to do it right in the first place--an odd approach to take
IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill"
wrote:


Actually, you don'thave to convert to a table to sort the second
list. In the Sort dialog, click on Options, choose Other, and
type a space in the box, then click OK. When you return to the
Sort dialog, you should have Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some
of the names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the
space in, say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column
contains the name you want to alphabetize on (simple if every
name has just a first name and a last name!), sort on that
column, and Convert back to Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the last
name, however I can'tfigure out how I did it. I am using Word
2003.---



  #20   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

The usage of people who have a roman numeral varies considerably. My feeling
is that the "correct" version is without a comma. After all, you don't write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's. I
can attest that the Candler dynasty in Atlanta, which was up to six or seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first names,
you can
sort by either last name or first name, just as you could if the last
and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry dances
all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column
but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order
by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table
menu.
Click Options, and then click Other under Separate fields at. In the
text
box, type a space, and then click OK. In the Sort by list, click Word
2 (or
the field you want to sort by), and then complete the sort as usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space in
the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space
in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.---




  #21   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

The usage of people who have a roman numeral varies considerably. My feeling
is that the "correct" version is without a comma. After all, you don't write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's. I
can attest that the Candler dynasty in Atlanta, which was up to six or seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first names,
you can
sort by either last name or first name, just as you could if the last
and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry dances
all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column
but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order
by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table
menu.
Click Options, and then click Other under Separate fields at. In the
text
box, type a space, and then click OK. In the Sort by list, click Word
2 (or
the field you want to sort by), and then complete the sort as usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space in
the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space
in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.---


  #22   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Word Sorting

Time enough for a quick bandaid. I added another utility that will take
names in lists formatted like:

George Washington IX
Thomas Jefferson VII
James Madison IV

and covert them to:

George Washington, IX
Thomas Jefferson, VII
James Madison, IV

For sorting as:

Jefferson, Thomas, VII

Madison, James, IV

Washington, George, IX



Then the second macro will swap arrangement and remove the improper comma
separation:



Thomas Jefferson VII

James Madison IV

George Washington IX




Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub ArrangeAndSortNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
NumericalSuffixes oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending, Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False, LanguageID
_
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub
Sub ArrangeFirstThenLast()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If

SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False

NumericalSuffixes oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub
Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub
Sub NumericalSuffixes(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim i As Long
vOrigText = Array("III", "IV", "V", "VI", "VII", "VII", "IX", "X", "XI",
"XII", "XII", "XIV", _
"XV")
With oRngSearch.Find
.MatchWholeWord = True
.MatchWildcards = True
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = "([!,]) (" & vOrigText(i) & ")"
.Replacement.Text = "\1, \2"
Case Else
.Text = ", " & vOrigText(i)
.Replacement.Text = " " & vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub


Peter T. Daniels wrote:
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill"
wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first
names, you can
sort by either last name or first name, just as you could if the
last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry
dances all
around this without spelling it out (it does mention the
nonbreaking
spaces); it describes sorting by more than one word in a given
column but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort
order by
using a combination of regular spaces and nonbreaking spaces. Type
a regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort
on. For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the
Table menu.
Click Options, and then click Other under Separate fields at. In
the text
box, type a space, and then click OK. In the Sort by list, click
Word 2 (or
the field you want to sort by), and then complete the sort as
usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses "things that go wrong when I'm sorting," not in one that
actually tells you
how to do it right in the first place--an odd approach to take
IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill"
wrote:


Actually, you don'thave to convert to a table to sort the second
list. In the Sort dialog, click on Options, choose Other, and
type a space in the box, then click OK. When you return to the
Sort dialog, you should have Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some
of the names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the
space in, say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column
contains the name you want to alphabetize on (simple if every
name has just a first name and a last name!), sort on that
column, and Convert back to Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the last
name, however I can'tfigure out how I did it. I am using Word
2003.---



  #23   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Word Sorting


Time enough for a quick bandaid. I added another utility that will take
names in lists formatted like:

George Washington IX
Thomas Jefferson VII
James Madison IV

and covert them to:

George Washington, IX
Thomas Jefferson, VII
James Madison, IV

For sorting as:

Jefferson, Thomas, VII

Madison, James, IV

Washington, George, IX



Then the second macro will swap arrangement and remove the improper comma
separation:



Thomas Jefferson VII

James Madison IV

George Washington IX




Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub ArrangeAndSortNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
NumericalSuffixes oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending, Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False, LanguageID
_
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub
Sub ArrangeFirstThenLast()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If

SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False

NumericalSuffixes oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub
Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub
Sub NumericalSuffixes(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim i As Long
vOrigText = Array("III", "IV", "V", "VI", "VII", "VII", "IX", "X", "XI",
"XII", "XII", "XIV", _
"XV")
With oRngSearch.Find
.MatchWholeWord = True
.MatchWildcards = True
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = "([!,]) (" & vOrigText(i) & ")"
.Replacement.Text = "\1, \2"
Case Else
.Text = ", " & vOrigText(i)
.Replacement.Text = " " & vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub


Peter T. Daniels wrote:
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill"
wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first
names, you can
sort by either last name or first name, just as you could if the
last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry
dances all
around this without spelling it out (it does mention the
nonbreaking
spaces); it describes sorting by more than one word in a given
column but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort
order by
using a combination of regular spaces and nonbreaking spaces. Type
a regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort
on. For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the
Table menu.
Click Options, and then click Other under Separate fields at. In
the text
box, type a space, and then click OK. In the Sort by list, click
Word 2 (or
the field you want to sort by), and then complete the sort as
usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses "things that go wrong when I'm sorting," not in one that
actually tells you
how to do it right in the first place--an odd approach to take
IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill"
wrote:


Actually, you don'thave to convert to a table to sort the second
list. In the Sort dialog, click on Options, choose Other, and
type a space in the box, then click OK. When you return to the
Sort dialog, you should have Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some
of the names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the
space in, say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column
contains the name you want to alphabetize on (simple if every
name has just a first name and a last name!), sort on that
column, and Convert back to Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the last
name, however I can'tfigure out how I did it. I am using Word
2003.---



  #24   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Word Sorting

I agree that no comma before numerical suffixes looks best. I was just
tinkering when I wrote those macros and wasn't paying much attention to
form. I don't even know if I considered numerical suffixes at the time.

A single solution for all the varialbes that can come into play with sorting
a list of names, particularily a list of names that someone else has
prepared may, simply not be possible.

"Jr." "Sr." "JR" "SR" without the comma could be included in the array with
"III", "IV", "V" ect. though.

Suzanne S. Barnhill wrote:
The usage of people who have a roman numeral varies considerably. My
feeling is that the "correct" version is without a comma. After all,
you don't write "Louis, XIV" or "King George, III." But many people
do include a comma, whether out of family tradition or ignorance,
their own or a secretary's. I can attest that the Candler dynasty in
Atlanta, which was up to six or seven when I was working in the
Development Office at Emory, do not use a comma. Thanks to the
leveling influence of the USPS, which prefers all caps and no commas,
even the comma before "Jr." is becoming lost.

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill"
wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first
names, you can
sort by either last name or first name, just as you could if the
last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry
dances all
around this without spelling it out (it does mention the
nonbreaking spaces); it describes sorting by more than one word in
a given column but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort
order by
using a combination of regular spaces and nonbreaking spaces. Type
a regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the
Table menu.
Click Options, and then click Other under Separate fields at. In
the text
box, type a space, and then click OK. In the Sort by list, click
Word 2 (or
the field you want to sort by), and then complete the sort as
usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take
IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill"
wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space
in the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the
space in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.---



  #25   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Word Sorting


I agree that no comma before numerical suffixes looks best. I was just
tinkering when I wrote those macros and wasn't paying much attention to
form. I don't even know if I considered numerical suffixes at the time.

A single solution for all the varialbes that can come into play with sorting
a list of names, particularily a list of names that someone else has
prepared may, simply not be possible.

"Jr." "Sr." "JR" "SR" without the comma could be included in the array with
"III", "IV", "V" ect. though.

Suzanne S. Barnhill wrote:
The usage of people who have a roman numeral varies considerably. My
feeling is that the "correct" version is without a comma. After all,
you don't write "Louis, XIV" or "King George, III." But many people
do include a comma, whether out of family tradition or ignorance,
their own or a secretary's. I can attest that the Candler dynasty in
Atlanta, which was up to six or seven when I was working in the
Development Office at Emory, do not use a comma. Thanks to the
leveling influence of the USPS, which prefers all caps and no commas,
even the comma before "Jr." is becoming lost.

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill"
wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first
names, you can
sort by either last name or first name, just as you could if the
last and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry
dances all
around this without spelling it out (it does mention the
nonbreaking spaces); it describes sorting by more than one word in
a given column but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort
order by
using a combination of regular spaces and nonbreaking spaces. Type
a regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the
Table menu.
Click Options, and then click Other under Separate fields at. In
the text
box, type a space, and then click OK. In the Sort by list, click
Word 2 (or
the field you want to sort by), and then complete the sort as
usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take
IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill"
wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space
in the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the
space in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.---





  #26   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15*pm, "Suzanne S. Barnhill" wrote:
The usage of people who have a roman numeral varies considerably. My feeling
is that the "correct" version is without a comma. After all, you don't write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's. I
can attest that the Candler dynasty in Atlanta, which was up to six or seven
when I was working in the Development Office at Emory, do not use a comma..
Thanks to the leveling influence of the USPS, which prefers all caps and no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:



The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.


The first will take a list of names like


A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III


and rearrange and sort as:


Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.


The second will take


Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.


and rearrange as:


Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra


The third is a utility for dealing the hypenated last names.


Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean


Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub


Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub


Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub


On Jan 15, 6:56 am, "Peter T. Daniels" wrote:


Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first names,
you can
sort by either last name or first name, just as you could if the last
and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry dances
all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column
but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order
by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table
menu.
Click Options, and then click Other under Separate fields at. In the
text
box, type a space, and then click OK. In the Sort by list, click Word
2 (or
the field you want to sort by), and then complete the sort as usual.."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take IMO)..


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space in
the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space
in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.----

  #27   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15*pm, "Suzanne S. Barnhill" wrote:
The usage of people who have a roman numeral varies considerably. My feeling
is that the "correct" version is without a comma. After all, you don't write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's. I
can attest that the Candler dynasty in Atlanta, which was up to six or seven
when I was working in the Development Office at Emory, do not use a comma..
Thanks to the leveling influence of the USPS, which prefers all caps and no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:



The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.


The first will take a list of names like


A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III


and rearrange and sort as:


Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.


The second will take


Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.


and rearrange as:


Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra


The third is a utility for dealing the hypenated last names.


Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean


Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub


Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub


Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub


On Jan 15, 6:56 am, "Peter T. Daniels" wrote:


Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first names,
you can
sort by either last name or first name, just as you could if the last
and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry dances
all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column
but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order
by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table
menu.
Click Options, and then click Other under Separate fields at. In the
text
box, type a space, and then click OK. In the Sort by list, click Word
2 (or
the field you want to sort by), and then complete the sort as usual.."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take IMO)..


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space in
the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space
in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.----

  #28   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

I think it's the comma after that is regarded as intrusive. People have the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the need
for the one after as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:
The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and
no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:



The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.


The first will take a list of names like


A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III


and rearrange and sort as:


Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.


The second will take


Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.


and rearrange as:


Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra


The third is a utility for dealing the hypenated last names.


Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean


Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub


Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub


Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub


On Jan 15, 6:56 am, "Peter T. Daniels" wrote:


Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first names,
you can
sort by either last name or first name, just as you could if the
last
and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry dances
all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given
column
but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order
by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the
Table
menu.
Click Options, and then click Other under Separate fields at. In the
text
box, type a space, and then click OK. In the Sort by list, click
Word
2 (or
the field you want to sort by), and then complete the sort as
usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill"
wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space
in
the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the
space
in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.----


  #29   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

I think it's the comma after that is regarded as intrusive. People have the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the need
for the one after as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:
The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and
no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:



The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.


The first will take a list of names like


A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III


and rearrange and sort as:


Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.


The second will take


Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.


and rearrange as:


Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra


The third is a utility for dealing the hypenated last names.


Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean


Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub


Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub


Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub


On Jan 15, 6:56 am, "Peter T. Daniels" wrote:


Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first names,
you can
sort by either last name or first name, just as you could if the
last
and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry dances
all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given
column
but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order
by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the
Table
menu.
Click Options, and then click Other under Separate fields at. In the
text
box, type a space, and then click OK. In the Sort by list, click
Word
2 (or
the field you want to sort by), and then complete the sort as
usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill"
wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space
in
the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the
space
in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.----


  #30   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

No one complains about "Robert A. Hall, Jr., wrote an idiosyncratic
textbook" -- they might thing it's old-fashioned, but it's how it's
been done for generations. Aren't we advised to avoid expressions like
"the Queen of England's son" anyway?

On Jan 17, 9:11*am, "Suzanne S. Barnhill" wrote:
I think it's the comma after that is regarded as intrusive. People have the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the need
for the one after as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:



The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and
no
commas, even the comma before "Jr." is becoming lost.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write


Joe A. Miller, Jr.
Joe A. Miller III


(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)



  #31   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

No one complains about "Robert A. Hall, Jr., wrote an idiosyncratic
textbook" -- they might thing it's old-fashioned, but it's how it's
been done for generations. Aren't we advised to avoid expressions like
"the Queen of England's son" anyway?

On Jan 17, 9:11*am, "Suzanne S. Barnhill" wrote:
I think it's the comma after that is regarded as intrusive. People have the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the need
for the one after as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:



The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and
no
commas, even the comma before "Jr." is becoming lost.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write


Joe A. Miller, Jr.
Joe A. Miller III


(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

  #32   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Word Sorting

I can't resist chiming in. :-)

In my former life as a textbook copy editor -- 30 years ago, but it
seems like yesterday -- I was taught that there are usually several
ways to express the same idea. It's the editor's job to suggest one
that best avoids ambiguity and awkward construction. In this case I
would suggest "an idiosyncratic textbook by Robert A. Hall, Jr." The
comma after Hall could be included or omitted according to the house
style. The comma between Jr. and the apostophe just disappears into
the sunset.

--
Jay

On Sun, 17 Jan 2010 09:32:31 -0800 (PST), "Peter T. Daniels"
wrote:

No one complains about "Robert A. Hall, Jr., wrote an idiosyncratic
textbook" -- they might thing it's old-fashioned, but it's how it's
been done for generations. Aren't we advised to avoid expressions like
"the Queen of England's son" anyway?

On Jan 17, 9:11*am, "Suzanne S. Barnhill" wrote:
I think it's the comma after that is regarded as intrusive. People have the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the need
for the one after as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:



The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and
no
commas, even the comma before "Jr." is becoming lost.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write


Joe A. Miller, Jr.
Joe A. Miller III


(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

  #33   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Word Sorting

I can't resist chiming in. :-)

In my former life as a textbook copy editor -- 30 years ago, but it
seems like yesterday -- I was taught that there are usually several
ways to express the same idea. It's the editor's job to suggest one
that best avoids ambiguity and awkward construction. In this case I
would suggest "an idiosyncratic textbook by Robert A. Hall, Jr." The
comma after Hall could be included or omitted according to the house
style. The comma between Jr. and the apostophe just disappears into
the sunset.

--
Jay

On Sun, 17 Jan 2010 09:32:31 -0800 (PST), "Peter T. Daniels"
wrote:

No one complains about "Robert A. Hall, Jr., wrote an idiosyncratic
textbook" -- they might thing it's old-fashioned, but it's how it's
been done for generations. Aren't we advised to avoid expressions like
"the Queen of England's son" anyway?

On Jan 17, 9:11*am, "Suzanne S. Barnhill" wrote:
I think it's the comma after that is regarded as intrusive. People have the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the need
for the one after as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in ...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:



The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and
no
commas, even the comma before "Jr." is becoming lost.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write


Joe A. Miller, Jr.
Joe A. Miller III


(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

  #34   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

Indeed, and that is the approach that I take in editing as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Jay Freedman" wrote in message
...
I can't resist chiming in. :-)

In my former life as a textbook copy editor -- 30 years ago, but it
seems like yesterday -- I was taught that there are usually several
ways to express the same idea. It's the editor's job to suggest one
that best avoids ambiguity and awkward construction. In this case I
would suggest "an idiosyncratic textbook by Robert A. Hall, Jr." The
comma after Hall could be included or omitted according to the house
style. The comma between Jr. and the apostophe just disappears into
the sunset.

--
Jay

On Sun, 17 Jan 2010 09:32:31 -0800 (PST), "Peter T. Daniels"
wrote:

No one complains about "Robert A. Hall, Jr., wrote an idiosyncratic
textbook" -- they might thing it's old-fashioned, but it's how it's
been done for generations. Aren't we advised to avoid expressions like
"the Queen of England's son" anyway?

On Jan 17, 9:11 am, "Suzanne S. Barnhill" wrote:
I think it's the comma after that is regarded as intrusive. People have
the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the
need
for the one after as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:



The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a
comma,
whether out of family tradition or ignorance, their own or a
secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a
comma.
Thanks to the leveling influence of the USPS, which prefers all caps
and
no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)



  #35   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Word Sorting

Indeed, and that is the approach that I take in editing as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Jay Freedman" wrote in message
...
I can't resist chiming in. :-)

In my former life as a textbook copy editor -- 30 years ago, but it
seems like yesterday -- I was taught that there are usually several
ways to express the same idea. It's the editor's job to suggest one
that best avoids ambiguity and awkward construction. In this case I
would suggest "an idiosyncratic textbook by Robert A. Hall, Jr." The
comma after Hall could be included or omitted according to the house
style. The comma between Jr. and the apostophe just disappears into
the sunset.

--
Jay

On Sun, 17 Jan 2010 09:32:31 -0800 (PST), "Peter T. Daniels"
wrote:

No one complains about "Robert A. Hall, Jr., wrote an idiosyncratic
textbook" -- they might thing it's old-fashioned, but it's how it's
been done for generations. Aren't we advised to avoid expressions like
"the Queen of England's son" anyway?

On Jan 17, 9:11 am, "Suzanne S. Barnhill" wrote:
I think it's the comma after that is regarded as intrusive. People have
the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the
need
for the one after as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.

They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".

On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:



The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a
comma,
whether out of family tradition or ignorance, their own or a
secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a
comma.
Thanks to the leveling influence of the USPS, which prefers all caps
and
no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)





  #36   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

I was writing to a newsgroup and chose to epater the bourgeois.

On Jan 17, 3:49*pm, "Suzanne S. Barnhill" wrote:
Indeed, and that is the approach that I take in editing as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Jay Freedman" wrote in message

...



I can't resist chiming in. :-)


In my former life as a textbook copy editor -- 30 years ago, but it
seems like yesterday -- I was taught that there are usually several
ways to express the same idea. It's the editor's job to suggest one
that best avoids ambiguity and awkward construction. In this case I
would suggest "an idiosyncratic textbook by Robert A. Hall, Jr." The
comma after Hall could be included or omitted according to the house
style. The comma between Jr. and the apostophe just disappears into
the sunset.


--
Jay


On Sun, 17 Jan 2010 09:32:31 -0800 (PST), "Peter T. Daniels"
wrote:


No one complains about "Robert A. Hall, Jr., wrote an idiosyncratic
textbook" -- they might thing it's old-fashioned, but it's how it's
been done for generations. Aren't we advised to avoid expressions like
"the Queen of England's son" anyway?


On Jan 17, 9:11 am, "Suzanne S. Barnhill" wrote:
I think it's the comma after that is regarded as intrusive. People have
the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the
need
for the one after as well.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.


They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".


On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:


The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a
comma,
whether out of family tradition or ignorance, their own or a
secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a
comma.
Thanks to the leveling influence of the USPS, which prefers all caps
and
no
commas, even the comma before "Jr." is becoming lost.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write


Joe A. Miller, Jr.
Joe A. Miller III


(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)-

  #37   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

I was writing to a newsgroup and chose to epater the bourgeois.

On Jan 17, 3:49*pm, "Suzanne S. Barnhill" wrote:
Indeed, and that is the approach that I take in editing as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

"Jay Freedman" wrote in message

...



I can't resist chiming in. :-)


In my former life as a textbook copy editor -- 30 years ago, but it
seems like yesterday -- I was taught that there are usually several
ways to express the same idea. It's the editor's job to suggest one
that best avoids ambiguity and awkward construction. In this case I
would suggest "an idiosyncratic textbook by Robert A. Hall, Jr." The
comma after Hall could be included or omitted according to the house
style. The comma between Jr. and the apostophe just disappears into
the sunset.


--
Jay


On Sun, 17 Jan 2010 09:32:31 -0800 (PST), "Peter T. Daniels"
wrote:


No one complains about "Robert A. Hall, Jr., wrote an idiosyncratic
textbook" -- they might thing it's old-fashioned, but it's how it's
been done for generations. Aren't we advised to avoid expressions like
"the Queen of England's son" anyway?


On Jan 17, 9:11 am, "Suzanne S. Barnhill" wrote:
I think it's the comma after that is regarded as intrusive. People have
the
same problem with "Inc." set off by commas, and I know you've seen how
difficult it is to get people to put the comma after years in dates or
states with city names. By omitting the comma before, you obviate the
need
for the one after as well.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
The overly permissive current (15th) edition of the Chicago Manual of
Style allows no-comma before Jr. and Sr. as well as before numbers,
and younger writers actually prefer to do it that way.


They objected when I wrote "Robert A. Hall, Jr.,'s idiosyncratic
textbook".


On Jan 16, 5:15 pm, "Suzanne S. Barnhill" wrote:


The usage of people who have a roman numeral varies considerably. My
feeling
is that the "correct" version is without a comma. After all, you don't
write
"Louis, XIV" or "King George, III." But many people do include a
comma,
whether out of family tradition or ignorance, their own or a
secretary's.
I
can attest that the Candler dynasty in Atlanta, which was up to six or
seven
when I was working in the Development Office at Emory, do not use a
comma.
Thanks to the leveling influence of the USPS, which prefers all caps
and
no
commas, even the comma before "Jr." is becoming lost.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"Peter T. Daniels" wrote in
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write


Joe A. Miller, Jr.
Joe A. Miller III


(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)-

  #38   Report Post  
Posted to microsoft.public.word.docmanagement
JERRY JERRY is offline
external usenet poster
 
Posts: 288
Default Word Sorting

But the "leveling influence of the USPS" also causes those poor souls with a
Roman numeral after their names to receive mail with a salutation that says,
"Dear Mr. III."

Jerry Doe III

"Suzanne S. Barnhill" wrote:

The usage of people who have a roman numeral varies considerably. My feeling
is that the "correct" version is without a comma. After all, you don't write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's. I
can attest that the Candler dynasty in Atlanta, which was up to six or seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first names,
you can
sort by either last name or first name, just as you could if the last
and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry dances
all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column
but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order
by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table
menu.
Click Options, and then click Other under Separate fields at. In the
text
box, type a space, and then click OK. In the Sort by list, click Word
2 (or
the field you want to sort by), and then complete the sort as usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space in
the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space
in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.---


.

  #39   Report Post  
Posted to microsoft.public.word.docmanagement
JERRY JERRY is offline
external usenet poster
 
Posts: 288
Default Word Sorting


But the "leveling influence of the USPS" also causes those poor souls with a
Roman numeral after their names to receive mail with a salutation that says,
"Dear Mr. III."

Jerry Doe III

"Suzanne S. Barnhill" wrote:

The usage of people who have a roman numeral varies considerably. My feeling
is that the "correct" version is without a comma. After all, you don't write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's. I
can attest that the Candler dynasty in Atlanta, which was up to six or seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and no
commas, even the comma before "Jr." is becoming lost.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Peter T. Daniels" wrote in message
...
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write

Joe A. Miller, Jr.
Joe A. Miller III

(and when I had a tour of the University of Virginia many years ago,
more than one of the name placards on the elite rooms -- the cottages
designed by Thomas Jefferson -- had a VII. By now there might be a
ninth generation of boys with the same name.)

On Jan 16, 2:55 pm, Greg Maxey wrote:
The process for sorting a list of names gets more and more complex as
the variety of name formats increase. Then there is the complication
of hyphnated last names and suffixes. Follows is a group of macros
that represents the closest I have been able to come sorting
correctly. Both requires any suffixes to be separtate with a comma.

The first will take a list of names like

A. A. Zebra
Zeke J. Applebee
Joe A. Miller, III

and rearrange and sort as:

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

The second will take

Applebee, Zeke J.
Miller, Joe A., III
Zebra, A. A.

and rearrange as:

Zeke J. Applebee
Joe A. Miller, III
A. A. Zebra

The third is a utility for dealing the hypenated last names.

Option Explicit
Dim oPar As Paragraph
Dim oRng As Word.Range
Dim oRngSelected As Range
Dim bEndofDoc As Boolean

Sub SortAndArrangeNames()
Set oRngSelected = Selection.Range
If oRngSelected.Paragraphs.Count 2 Then
MsgBox "There is no valid selection to sort"
Exit Sub
End If
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
Else
oRng.End = oRng.End - 1
oRng.InsertBefore Trim(oRng.Words(oRng.Words.Count)) & ", "
oRng.Words(oRng.Words.Count).Delete
End If
Next
oRngSelected.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByTabs, SortColumn:=False, CaseSensitive:=False,
LanguageID _
:=wdEnglishUS
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SwapLastAndFirst()
Dim pStr As String
Set oRngSelected = Selection.Range
bEndofDoc = False
If oRngSelected.End = ActiveDocument.Range.End Then
bEndofDoc = True
oRngSelected.InsertAfter vbCr
oRngSelected.MoveEnd wdParagraph, -1
End If
SetRemoveFlags oRngSelected, True
For Each oPar In oRngSelected.Paragraphs
Set oRng = oPar.Range
With oRng
pStr = " " & .Words.First.Text
.Collapse wdCollapseStart
.End = .Words.First.End + 2
.Delete
End With
Set oRng = oPar.Range
If InStr(oPar.Range.Text, ",") 0 Then
oRng.End = oRng.Start + InStr(oPar.Range.Text, ",") - 1
oRng.InsertAfter pStr
Else
oRng.End = oRng.End - 1
oRng.InsertAfter pStr
End If
Next
SetRemoveFlags oRngSelected, False
Selection.Collapse wdCollapseStart
If bEndofDoc Then ActiveDocument.Range.Paragraphs.Last.Range.Delete
End Sub

Sub SetRemoveFlags(ByRef oRngSearch As Word.Range, bSet As Boolean)
Dim vOrigText As Variant
Dim vFlagText As Variant
Dim i As Long
vOrigText = Array("-", Asc(30))
vFlagText = Array("XxXx", "YyYy")
With oRngSearch.Find
For i = 0 To UBound(vOrigText)
Select Case bSet
Case True
.Text = vOrigText(i)
.Replacement.Text = vFlagText(i)
Case Else
.Text = vFlagText(i)
.Replacement.Text = vOrigText(i)
End Select
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

On Jan 15, 6:56 am, "Peter T. Daniels" wrote:



Help is so helpful!


Presumably one can write a macro to change all but the last space in
an entry to nonbreaking space.


On Jan 14, 11:05 pm, "Suzanne S. Barnhill" wrote:


Word 2003's Help topic "About sorting" contains this intriguing
paragraph:


"You can also sort by more than one word or field inside a single
table
column. For example, if a column contains both last and first names,
you can
sort by either last name or first name, just as you could if the last
and
first names were in a list instead of a table."


There's an illustration that shows "Last Name, First Name" in what
appears
to be a single table column. The "Troubleshoot sorting" entry dances
all
around this without spelling it out (it does mention the nonbreaking
spaces); it describes sorting by more than one word in a given column
but
appears to say nothing about using any but the first word as the
primary
sort key until you get to the very end:


"If you've already typed the entries, you can control the sort order
by
using a combination of regular spaces and nonbreaking spaces. Type a
regular
space between fields you want to sort on, and press
CTRL+SHIFT+SPACEBAR to
insert a nonbreaking space between fields you don'twant to sort on.
For
example, type Dr.nonbreaking spaceJohn Smith or John
Smith,nonbreaking
spaceM.D. Then select the list or table, and click Sort on the Table
menu.
Click Options, and then click Other under Separate fields at. In the
text
box, type a space, and then click OK. In the Sort by list, click Word
2 (or
the field you want to sort by), and then complete the sort as usual."


So yes, this is documented, but you have to wade through a lot of
other
stuff to get to it (and you can find it only in an article that
addresses
"things that go wrong when I'm sorting," not in one that actually
tells you
how to do it right in the first place--an odd approach to take IMO).


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
Wow. As someone said yesterday, Is that documented anywhere?


On Jan 14, 5:10 pm, "Suzanne S. Barnhill" wrote:


Actually, you don'thave to convert to a table to sort the second
list. In
the Sort dialog, click on Options, choose Other, and type a space in
the
box, then click OK. When you return to the Sort dialog, you should
have
Word
1 and Word 2 as options under "Sort by." Choose Word 2. If some of
the
names
have middle names or initials, you'll need to prepare the list by
substituting a nonbreaking space (Ctrl+Shift+Spacebar) for the space
in,
say, "PeterT." or "Mary Ann."


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org


"PeterT.Daniels" wrote in
...
If they're in the form


Roe, Richard
Doe, John


(each name its own paragraph) then all you do is select the whole
list
and choose Table Sort (they don'thave to be in a table).


If they're in the form


Richard Roe
John Doe


then you need to Convert to Table where the second column contains
the
name you want to alphabetize on (simple if every name has just a
first
name and a last name!), sort on that column, and Convert back to
Text.


On Jan 14, 1:51 pm, u50st wrote:


I swear I used to be able to sort a list of first and last names
by the
last
name, however I can'tfigure out how I did it. I am using Word
2003.---


.

  #40   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Word Sorting

Um, it isn't the USPS that designed the software that extracts the
names from someone's contact list ...

On Jan 18, 10:53*am, Jerry wrote:
But the "leveling influence of the USPS" also causes those poor souls with a
Roman numeral after their names to receive mail with a salutation that says,
"Dear Mr. III."

Jerry Doe III



"Suzanne S. Barnhill" wrote:
The usage of people who have a roman numeral varies considerably. My feeling
is that the "correct" version is without a comma. After all, you don't write
"Louis, XIV" or "King George, III." But many people do include a comma,
whether out of family tradition or ignorance, their own or a secretary's. I
can attest that the Candler dynasty in Atlanta, which was up to six or seven
when I was working in the Development Office at Emory, do not use a comma.
Thanks to the leveling influence of the USPS, which prefers all caps and no
commas, even the comma before "Jr." is becoming lost.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org


"Peter T. Daniels" wrote in message
....
I figured you'd come through with a solution ... in the last one, is
the comma essential? Because usually one would write


Joe A. Miller, Jr.
Joe A. Miller III

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting in a Word Table Brian Pope Tables 1 November 11th 09 08:46 AM
Sorting - Word '07 ml20090412 Tables 0 August 4th 09 07:51 PM
Sorting data in MS Word 2002 akkrug New Users 6 June 17th 09 02:04 PM
Word template sorting txfireman Microsoft Word Help 1 September 30th 08 09:02 PM
Word XP mailmerge and Sorting shawn Mailmerge 1 October 5th 07 06:01 AM


All times are GMT +1. The time now is 02:21 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"