View Single Post
 
Old 08-18-2019, 01:59 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Based on what you have shown and described:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim varFactors
Dim lngIndex As Long
Dim strFind As String
Dim oRng As Range
Dim strDesc As String

  varFactors = Split(Selection.Text, ",")
  strDesc = InputBox("Enter a decriptor")
  For lngIndex = 0 To UBound(varFactors)
    Set oRng = ActiveDocument.Range
    With oRng.Find
      .Text = Trim(varFactors(lngIndex))
      .MatchCase = True
      While .Execute
        If oRng.InRange(Selection.Range) Then
          'If you need to expand the range of the defined text do it here before applying the BM
          oRng.Bookmarks.Add strDesc & lngIndex + 1, oRng
        End If
        oRng.Collapse wdCollapseEnd
      Wend
    End With
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote