PDA

View Full Version : Find string within a string and highlight



austenr
11-02-2012, 07:36 PM
Hey guys,

Haven't posted in a log long time. What I am trying to do is find the string "336rt70" in both Columns A & B and highlight green in the workbook attached. If it could be a formula with cond formatting that would be fine. I need to use this in a lot of workbooks.

shrivallabha
11-03-2012, 12:41 AM
Try:
Public Sub HighlightText()
Dim rng As Range
Const csStr As String = "336RT70"
For Each rng In ActiveSheet.UsedRange
If InStr(rng.Value, csStr) > 0 Then
With rng.Characters(Start:=InStr(rng.Value, csStr), Length:=Len(csStr))
.Font.Color = vbGreen
End With
End If
Next rng
End Sub

mikerickson
11-03-2012, 08:50 AM
Using AutoFilter with the Contains option might be easier than a helper column and CF.

austenr
11-03-2012, 10:20 AM
thanks mikerickson that was easier.

austenr
11-04-2012, 12:28 PM
Is there a way to filter col A in the OP attachment and also show what goes with it in col B? Filter col A on contains 336rt70.

mikerickson
11-04-2012, 02:13 PM
Put the group name in every row that has a member in it.
You can use CF to hide all but the first group name