Forum Discussion
highlight / color change, a particular character in a cell of a worksheet
Hi biju1011
Sub ChangeIncellCharacterColour()
Dim rSelectedRange As Range
Dim vMyCharacter As Variant
Dim c As Integer
Dim rCell As Range
Dim lColourIndex As Long
On Error GoTo HandleErrors
vMyCharacter = 9
lColourIndex = -16776961
Set rSelectedRange = Selection
'Loop all cells in the selected
For Each rCell In rSelectedRange
'Loop characters in the current cell
For c = 1 To Len(rCell)
'Set colour of the character if it's value matches our parameter
If rCell.Characters(c, Len(vMyCharacter)).Text = vMyCharacter Then
rCell.Characters(c, Len(vMyCharacter)).Font.Color = lColourIndex
End If
Next c
Next rCell
HandleErrors:
End Sub
Hope this is helpful. Please hit 'like' if you like my answer :)
Kind regards
Yury