
Originally Posted by
rinocerinho
are you sure this can only be accomplished with VBA?
If you're happy to manually set the font of each character in the string, no.
If you wish to automate the process, yes.
Conditional Formatting, Custom Formatting are applied at a cell level rather than at an individual character level within the cell itself.
In terms of a VBA process...
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngInterest As Range, rngCell As Range, lngPos As Long, lngColour As Long
On Error Resume Next
Set rngInterest = Intersect(Target, Columns("A"))
On Error GoTo ExitPoint
If rngInterest Is Nothing Then GoTo ExitPoint
For Each rngCell In rngInterest.Cells
For lngPos = 1 To Len(rngCell.Value) Step 1
Select Case UCase(Mid(rngCell.Value, lngPos, 1))
Case "W" 'White
lngColour = 2
Case "U" 'Blue
lngColour = 23
Case "B" 'Black
lngColour = 1
Case "R" 'Red
lngColour = 3
Case "G" 'Green
lngColour = 10
End Select
rngCell.Characters(lngPos, 1).Font.ColorIndex = lngColour
Next lngPos
Next rngCell
ExitPoint:
Set rngInterest = Nothing
End Sub
To use the above, right click on the tab name containing the values of interest, select View Code and paste the above into the resulting window.
Thereafter, in a Macro enabled file, you will find that altering the values in Column A will lead to them being formatted as per your wishes.
I would state that formatting font as white is obviously risky unless you have modified the background fill colour (to something other than those colours used above).
You will need to save the file in a macro supported type - eg .xlsm ... or if you want to run in Compatibility Mode save as old .xls
Modify ranges etc to suit your own requirements... the above is meant purely as an example.
Bookmarks