View Single Post
 
Old 01-12-2018, 05:48 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

That's what your example showed. If you want to check the last word in the document against the list, then set the range end there instead. e.g.

Code:
Sub Macro1()
'Graham Mayor - http://www.gmayor.com - Last updated - 12 Jan 2018
Dim oRng As Range
Dim strEndWord() As Variant
Dim i As Long
    strEndWord = Array("so", "jas", "mf")
    Set oRng = Selection.Paragraphs(1).Range
    With oRng
        .Font.Bold = True
        .End = .Words(1).End - 1
        .InsertAfter ChrW(9658)
        .End = .End + 1
        .Font.ColorIndex = wdRed
        .End = ActiveDocument.Range.End - 1
        .Start = .Words.Last.Start
        For i = 0 To UBound(strEndWord)
            If strEndWord(i) = LCase(.Text) Then
                .InsertBefore vbTab
                .Font.Bold = True
                Exit For
            End If
        Next i
    End With
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote