calling for help again for xls 2003

D

driller

Hello to all,

I got a mystical problem in tracking the bulk of continuous changes made in
a monitoring worksheet.

I need to count the number of cells in a worksheet that contains a specific
color of text.

e.g
In A1 contains text like this "The quick brown fox jumps over the lazy dog."

if the text "lazy dog" is colored red while the others are in black or blue
or whatever,
is it possible to count A1 as part of the cells that has red text in it...by
macro.?

I hope that this is possible, otherwise I am caught in a big mess counting
with my fingers these cells with red text in a group of text along thousands
of cells.

thanks for any advice or suggestion.
 
N

NateBuckley

Try this out :) I've tested it and it worked for me, you might need to change
the If check for the colour, as I was going off the colour index 3 which is a
bright red. Unsure about that.

Sub CountInstancesOfRed()
Dim count As Integer
Dim i As Integer
Dim strLen As Integer
Dim aRange As Range
Set aRange = Sheet1.Range("A1:A10")
For Each c In aRange
strLen = Len(c.Value)
For i = 1 To strLen
With c.Characters(Start:=i, Length:=1).Font
If .ColorIndex = 3 Then
count = count + 1
Exit For
End If
End With
Next i
Next c
MsgBox count
End Sub
 
D

driller

tnaks and sorry for a late reply,

i've tested the macro, the pop-up result always shows a "0".

I may have missed something.
 

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

Top