I would like to write a VBA function to highlight specific text within an excel cell. Is this possible? I've been googling but it's unclear at this point.
to clarify, I would like to search a specific column for a text value (actually a list of values) and highlight the matched text in say yellow.
Note: this is what I ended up doing:
Sub Colors()
Dim searchString As String
Dim targetString As String
Dim startPos As Integer
searchString = "abc"
targetString = Cells(2, 1).Value
startPos = InStr(targetString, searchString)
If startPos > 0 Then
Cells(2, 1).Characters(startPos, Len(searchString)).Font.Color = vbRed
End If
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…