Extracting font color within a range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
This should work:

For Each Character in Range(r).Characters
If Font.ColorIndex = 3 Then
'Do Something
End If
Next
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top