Hello!
I am trying to create a Macro/VBA to conditionally format text. I have 30+ text examples I'd like to highlight all the same color. For example, I'd like to highlight: "abc called", "abc understands", "abcdef called", etc. I don't know how to do this other than recording each and every 'text contains' in conditional formatting. I've got to assume Excel/VBA has this capability to perform in a Macro, I just don't know what to do. I can record Macros, but don't know how to write or modify them well. Any help is appreciated!
Example:
Columns("J:J").Select
Selection.FormatConditions.Add Type:=xlTextString, String:="abc called", _
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 = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlTextString, String:= _
"abc understands", 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 = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlTextString, String:="abcdef called" _
, 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 = 13561798
.TintAndShade = 0
So the above does what I need, but this will get rather lengthy. Can I combine multiple text to highlight in the same function?
Thank you!!!
I am trying to create a Macro/VBA to conditionally format text. I have 30+ text examples I'd like to highlight all the same color. For example, I'd like to highlight: "abc called", "abc understands", "abcdef called", etc. I don't know how to do this other than recording each and every 'text contains' in conditional formatting. I've got to assume Excel/VBA has this capability to perform in a Macro, I just don't know what to do. I can record Macros, but don't know how to write or modify them well. Any help is appreciated!
Example:
Columns("J:J").Select
Selection.FormatConditions.Add Type:=xlTextString, String:="abc called", _
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 = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlTextString, String:= _
"abc understands", 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 = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlTextString, String:="abcdef called" _
, 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 = 13561798
.TintAndShade = 0
So the above does what I need, but this will get rather lengthy. Can I combine multiple text to highlight in the same function?
Thank you!!!