View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Conditional Formatting from a group

Hi again,

Am Thu, 10 Oct 2013 22:37:50 +0200 schrieb Claus Busch:

substrings only can be colored by VBA.
Modify following code to your wishes:


a little bit faster:

Sub Color()
Dim arrGreen As Variant
Dim arrRed As Variant
Dim arrBlue As Variant
Dim rngC As Range
Dim LRow As Long
Dim i As Integer
Dim n As Integer
Dim intStart As Integer
Dim intLen As Integer

arrGreen = Array(789, 790, 791, 212)
arrRed = Array(123, 222, 541, 346, 718)
LRow = Cells(Rows.Count, 4).End(xlUp).Row
For Each rngC In Range("D1:D" & LRow)
For i = LBound(arrGreen) To UBound(arrGreen)
For n = 1 To Len(rngC)
intStart = InStr(n, rngC, arrGreen(i) & ".")
If intStart 0 Then
intLen = InStr(intStart, rngC, ",") - intStart
rngC.Characters(intStart, intLen).Font.Color = vbGreen
n = n + intStart + intLen
End If
Next
Next
For i = LBound(arrRed) To UBound(arrRed)
For n = 1 To Len(rngC)
intStart = InStr(n, rngC, arrRed(i) & ".")
If intStart 0 Then
intLen = InStr(intStart, rngC, ",") - intStart
rngC.Characters(intStart, intLen).Font.Color = vbRed
n = n + intStart + intLen
End If
Next
Next
Next
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2