I have a list of sentences, some of the characters in the sentences are colored green (colorindex = 10), some are colored blue (colorindex = 5) and some are colored black. I would like to calculate the proportion of each sentence which is colored either blue or green.
I have written a macro which loops through each character in each sentence and determines what color it is, then spits out the proportion of non-black colored characters in that sentence. The problem is that this is very slow, I believe there are more advanced techniques which can be used in VBA such as storing information in an array then spitting it out as an array at the end. I'm not too sure, if someone could may me make this faster it would be much appreciated!
The code in this query Count keywords within phrases does something very similar but in a fraction of the time.
Here is what I have so far: The sentences are in Range("B2:B1000")
Dim x As Integer, Black As Integer, y As Integer
x = 2
Do Until Cells(x, 2) = ""
Black = 0
For y = 1 To Len(Cells(x, 2))
If Cells(x, 2).Characters(y, 1).Font.ColorIndex = 1 Then
Black = Black + 1
Else
End If
Next y
Cells(x, 3).FormulaR1C1 = "=1-" & Black & "/LEN(RC[-1])"
x = x + 1
Loop