PDA

View Full Version : Alphabetical Order Via Surnames / Not First Word



VB-AN-IZ
09-10-2016, 08:06 AM
Is there a simple way to order a list of names via the second column of a table, or by the first word after a space?

I've recorded an idiotic macro that creates a table by turning each space into a different field, then sorting by the third word (where applicable), then second, then first word.

Doesn't always work, and I'm sure there's an easier way...?


Selection.WholeStory
Selection.Sort ExcludeHeader:=False, FieldNumber:="Word 2", SortFieldType _
:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending, FieldNumber2 _
:="", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending, Separator:= _
wdSortSeparateByDefaultTableSeparator, SortColumn:=False, CaseSensitive:= _
False, LanguageID:=wdEnglishUS, SubFieldNumber:="Paragraphs", _
SubFieldNumber2:="Paragraphs", SubFieldNumber3:="Paragraphs"
End Sub

gmaxey
09-10-2016, 02:00 PM
See if something here helps:

http://gregmaxey.mvps.org/word_tip_pages/sorting_lists_(macro_methods).html