L
lilac
I want to sort a list of titles, but items such as "The ABC" should be under
A not T. How do I do this?
A not T. How do I do this?
I want to sort a list of titles, but items such as "The ABC" should
be under A not T. How do I do this?
Word doesn't provide a way to do this unless you either put "The"
after the title ("ABC, The") or temporarily format "The" and A" as
Hidden Text, hide them, sort, and then remove the Hidden property.
Second option very neat. Learn something new everyday. You can also do
that with nails and hammers ;-)
Sub ScratchMacoII()
Dim oRng As Word.Range
Dim oPar As Paragraph
Dim oRngProcess
Dim pStr As String
Set oRng = Selection.Range
For Each oPar In oRng.Paragraphs
Select Case oPar.Range.Words.First
Case "The ", "A "
oPar.Range.Words.First.Font.Hidden = True
oPar.Range.Shading.BackgroundPatternColorIndex = wdBrightGreen
End Select
Next
Selection.Sort
For Each oPar In oRng.Paragraphs
Select Case oPar.Range.Shading.BackgroundPatternColorIndex
Case wdBrightGreen
oPar.Range.Words.First.Font.Hidden = False
oPar.Range.Shading.BackgroundPatternColorIndex = wdAuto
End Select
Next
End Sub
***Assumes of course that no paragraphs shading is used in the original
text.