Hi Jen,
assuming that your lines are paragraphs,
structured like that:
objCC.DropdownListEntries.Add "Dr Edward Rowel"¶
objCC.DropdownListEntries.Add "Dr Michael Adams"¶
Then I'd put the second last word in a paragraph
at the start of that paragraph.
Note that the paragraph mark is the last word
in a paragraph and that the closing quotation mark
is the second last word.
So the name is the third last word:
oprg.range.Words.count - 2
For Each oPrg In Selection.Paragraphs
sTmp = oPrg.Range.Words(oPrg.Range.Words.Count - 2)
oPrg.Range.InsertBefore sTmp & " "
Next
Then I'd sort the paragraphs:
Selection.Sort
Then I'd remove the first word again:
For Each oPrg In Selection.Paragraphs
oPrg.Range.Words(1).Delete
Next
All together:
Sub SortMe()
Dim sTmp As String
Dim oPrg As Paragraph
For Each oPrg In Selection.Paragraphs
sTmp = oPrg.Range.Words(oPrg.Range.Words.Count - 2)
oPrg.Range.InsertBefore sTmp & " "
Next
Selection.Sort
For Each oPrg In Selection.Paragraphs
oPrg.Range.Words(1).Delete
Next
End Sub
Which is far from being perfect,
just quick and dirty,
but setting up a quicksort,
working on the second last word in a paragraph,
was too much for me here and now.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP