View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 145
Default Extracting font color within a range


"Barb Reinhardt" wrote:

I have a range (I'm calling it r) that refers to a cell. I've found
that
the cell has multiple colorindeces. How do I extract the characters
where
the color index is RED only.

Thanks,
Barb Reinhardt


As a function:

Function GetRed(rng As Range) As String
Dim r As String, i As Long

r = ""
For i = 1 To Len(rng.Value)
If rng.Characters(i, 1).Font.ColorIndex = 3 Then
r = r & rng.Characters(i, 1).Text
End If
Next i
GetRed = r
End Function

Tim