Baby |
BABAlouie is the king of BAboons. |
dog |
DO … … DOor |
Lion |
The LIons are beatufil animals. |
Dog |
DOgland is the home of the animals. |
Sub DumberYet()
StrCol = 1
StrLen = 2
SentCol = 2
'LOOP THOUGH COLUMN 1 VALUES UNTIL BLANK
Set Rng = Columns(StrCol)
For Each aCell In Rng.Cells
If aCell.Value = "" Then Exit Sub
'UCASE ALL INSTANCES OF STRING IN SENTENCE
S_Loc = 1
Do
StrValue = Left(aCell.Value, StrLen)
SentValue = Cells(aCell.Row, SentCol).Value
I = InStr(S_Loc, UCase(SentValue), UCase(StrValue))
If I <> 0 Then
If I = 1 Then
Cells(aCell.Row, SentCol).Value = Left(UCase(SentValue), StrLen) & Right(SentValue, Len(SentValue) - I - 1)
Else
Cells(aCell.Row, SentCol).Value = Left(SentValue, I - 1) & Mid(UCase(SentValue), I, StrLen) & Right(SentValue, Len(SentValue) - I - 1)
End If
End If
S_Loc = I + StrLen
Loop Until I = 0
'BOLD ALL WORDS CONTAINING INSTANCES OF STRING
S_Loc = 1
Do
StrValue = Left(aCell.Value, StrLen)
SentValue = Cells(aCell.Row, SentCol).Value
I = InStr(S_Loc, UCase(SentValue), UCase(StrValue))
If I <> 0 Then
W_Start = I
Do Until (Mid(SentValue, I, 1) = " " Or Mid(SentValue, I, 1) = "." Or I >= Len(SentValue))
I = I + 1
Loop
W_Len = I - W_Start
Cells(aCell.Row, SentCol).Characters(Start:=W_Start, Length:=W_Len).Font.FontStyle = "Bold"
End If
S_Loc = I
Loop Until I = 0
Next aCell
End Sub