Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conditional format of part of text

Status
Not open for further replies.

mart10

MIS
Nov 2, 2007
394
GB
I am using Excel 2003

is it possible to conditionally format just part of some text in a cell to a different colour eg T-abcd-gyet-gb-123 . I want it to conditionally format the data between the first 2 dashes, but the text within this maybe of different length but will allways start at position 3 and end with the next dash
 
hi,

What conditional format? You have stated the portion of text that that want formatted, but you have stated nothing about 1) what CONDITION(s) will trigger the format and 2) what exact FORMAT(s) would be applied under each condition!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
This code in worksheet's module changes a part of text to red:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
i1 = InStr(1, Target, "-")
i2 = InStr(i1 + 1, Target, "-")
If i2 <> 0 Then
    Target.Characters(i1 + 1, i2 - i1 - 1).Font.ColorIndex = 3
End If
End Sub
The main limitation is that the text cannot be a result of formula.
You need to add conditions to the code above and, in case of using the "Change" event, validate changed range.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top