Assuming you have the data in Column "A" .. Try the following code:
Private Sub CommandButton1_Click()
Dim oCell As Range
Dim strTest As String
Dim strArray() As String
Dim X As Integer
Dim Y As Integer
Dim intLenStr() As Integer
Dim intStrIndex As String
Dim intStart As Integer
Dim strPos As String
Dim intCount As Integer
Dim i As Integer
Application.ScreenUpdating = False
On Error GoTo errHandle
For Each oCell In Range("A:A")
oCell.Offset(0, 1).ClearContents
intCount = intCount + 1
strTest = oCell.Value
strArray = Split(strTest, " ")
X = LBound(strArray)
Y = UBound(strArray)
ReDim intLenStr(X To Y)
intStart = 1
For i = X To Y
intStrIndex = i + 1 'Index the current string.
intLenStr(i) = Len(strArray(i))
With oCell.Characters(Start:=intStart, Length:=intLenStr(i)).Font
If .Underline = xlUnderlineStyleSingle Then
oCell.Offset(0, 1) = oCell.Offset(0, 1) & intStrIndex & ".."
End If
End With
intStart = intStart + intLenStr(i) + 1
Next i
Next oCell
Application.ScreenUpdating = True
errHandle:
Application.ScreenUpdating = True
MsgBox (intCount - 1) & " Rows checked", vbInformation
End Sub
Bookmarks