Thread: Alphabetizing
View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Alphabetizing

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
Word MVP web site http://word.mvps.org



"Fay Zeller" wrote in message
...
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?.