ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Custom Format font for "xx" to yellow (https://www.excelbanter.com/excel-discussion-misc-queries/149483-custom-format-font-xx-yellow.html)

nastech

Custom Format font for "xx" to yellow
 
can I Custom Format just the characters: xx to be a yellow font? thanks

Peo Sjoblom

Custom Format font for "xx" to yellow
 
Not possible using formatting


--
Regards,

Peo Sjoblom



"nastech" wrote in message
...
can I Custom Format just the characters: xx to be a yellow font? thanks




Gord Dibben

Custom Format font for "xx" to yellow
 
You could use a macro.

Sub Color_String()
Dim Rng As Range
Dim cell As Range
Dim start_str As Integer
Set Rng = Selection
For Each cell In Rng
start_str = InStr(cell.Value, "xx")
If start_str Then
cell.Characters(start_str, 2).Font.ColorIndex = 6
End If
Next
End Sub

Or make it a worksheet event. Paste into the sheet module.

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:A10"
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Dim Rng As Range
Dim cell As Range
Dim start_str As Integer
For Each cell In Target
start_str = InStr(cell.Value, "xx")
If start_str Then
cell.Characters(start_str, 2).Font.ColorIndex = 6
End If
Next
End If
ws_exit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP
On Mon, 9 Jul 2007 12:06:04 -0700, nastech
wrote:

can I Custom Format just the characters: xx to be a yellow font? thanks




All times are GMT +1. The time now is 04:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com