Is there a way to adjust the Excel VBA code to find and color a specific part of the text string found?
I am using the following code to find and highlight all cells with text string "@gmail.com" and "@yahoo.com" in column V. The text string in column V is like this:
BBC43555;johnsmith@gmail.com;77888857778;phone:0018888889
It cannot be divided into columns because it may contain different number and order of information fields combined in it.
I would like to highlight only the specific text string found. I would appreciate a simple solution with a good explanation, since I am just starting to collect experience with VBA.
Columns("V").Select
Selection.FormatConditions.Add Type:=xlTextString, String:="@gmail.com", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13421823
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlTextString, String:="@yahoo.com", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13421823
.TintAndShade = 0
End With