Alphabetizing

F

Fay Zeller

I need to take reservations for an event & note the # of people attending.
Therefore
1. Jane Smith
2. Edgar Guest
3. Joe Jones
4. Bob Able
5.Jennifer Boyer
6. David Hall
7. Bill Williams

After the list is complete I need to alphabetize, as going through a list of
200 people when they arrive takes too much time.
when I use the sorter it doesn't work because of the numbers, probably.
How can I alphabetize this list?.
 
G

Graham Mayor

If you have manually typed the numbers and the names are simple forename and
surname with each row as a new paragraph as in the example (and hopefully
all with the same format - as no 5 has a missing space between the period
and the forename) then the following macro will sort the list by surname and
renumber in the new order


Dim i As Long
ActiveDocument.Range.Select
WordBasic.TextToTable ConvertFrom:=3, _
InitialColWidth:=wdAutoPosition, _
format:=0, Apply:=1184, AutoFit:=0, _
SetDefault:=0, Word8:=0, Style:="Table Grid"
Selection.Sort ExcludeHeader:=False, FieldNumber:="Column 3", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="Column 2",
SortFieldType2:=wdSortFieldAlphanumeric, _
SortOrder2:=wdSortOrderAscending, FieldNumber3:="",
SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByCommas, SortColumn:=False, CaseSensitive:=False,
_
LanguageID:=wdEnglishUK, SubFieldNumber:="Paragraphs",
SubFieldNumber2:= _
"Paragraphs", SubFieldNumber3:="Paragraphs"
With ActiveDocument.Tables(1)
.Columns(1).Delete
.Rows.ConvertToText Separator:=" "
End With
With ActiveDocument
For i = 1 To .Paragraphs.Count
If Len(.Paragraphs(i).Range) > 2 Then
.Paragraphs(i).Range.InsertBefore i & ". "
End If
Next i
End With

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Suzanne S. Barnhill

There will be no problem with the numbers if you have used auto numbering
rather than typed the numbers. The hitch is that, by default, Word will sort
on the first name. To sort on the last name, in the Sort dialog, click
Options. Under "Separate fields at," choose "Other" and type a space in the
box, then click OK. You will now have a choice of Word 1 and Word 2. Sort on
Word 2. If any of the names have more than first name and last name, you
will need to do some work to make them conform. Replace the space between a
first name and middle initial or the two parts of a double first name with a
nonbreaking space (Ctrl+Shift+Spacebar), and Word will see them as one word.

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

Fay Zeller

Thanks to you all--Opinicus, Graham & Suzanne. I will try your suggestions.
They seem relatively easy, except Graham's, as I never really got into
macros.
But I hope to find the time to learn it one of these days or years.
Regards, Fay
 

Ask a Question

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

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

Ask a Question

Top