View Single Post
 
Old 03-16-2015, 11:42 AM
Snakehips Snakehips is offline Windows 8 Office 2013
Advanced Beginner
 
Join Date: Mar 2015
Posts: 36
Snakehips is on a distinguished road
Default

The following code will deal with your posted example or the slight variation below but after that it will get a whole lot harder.

My name is Bill and I am a professional bank robber .
My name is Dan and I am a police officer.
My name is Bill and I am a professional bank robber .

Code:
Sub Compare_Text()

Set ws = ActiveSheet
ws.Shapes("Textbox 3").TextFrame.Characters.Font.ColorIndex = 1

Arry1 = Split(ws.Shapes("Textbox 1").TextFrame.Characters.Text, " ")
Arry2 = Split(ws.Shapes("Textbox 2").TextFrame.Characters.Text, " ")

If UBound(Arry1) >= UBound(Arry2) Then
    Arry3 = Arry1
    Arry4 = Arry2
    ws.Shapes("Textbox 3").TextFrame.Characters.Text = ws.Shapes("Textbox 1").TextFrame.Characters.Text
    Else
    Arry3 = Arry2
    Arry4 = Arry1
    ws.Shapes("Textbox 3").TextFrame.Characters.Text = ws.Shapes("Textbox 2").TextFrame.Characters.Text
End If

For i = 0 To UBound(Arry1)
    wcc = Len(Arry3(i)) + 1
    tc = tc + wcc
    On Error Resume Next
    If Not Arry3(i) = Arry4(i) Then
         ws.Shapes("Textbox 3").TextFrame.Characters(tc - wcc, wcc).Font.ColorIndex = 3
     On Error GoTo 0
    End If
Next i

End Sub
Hope that helps give you a start.
Reply With Quote