ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   More Functions based on Font Color (https://www.excelbanter.com/new-users-excel/201096-more-functions-based-font-color.html)

michelle

More Functions based on Font Color
 
I'm trying to add the cells who's font color is red. What I have so far is

=SUMIF(F4:F116," ")

Am I close?

Bob Phillips[_3_]

More Functions based on Font Color
 
No. You need a UDF as well as a formula

Add this function

Function CellColours(rng As Range) As Variant
Dim ary As Variant
Dim cell As Range
Dim i As Long

ReDim ary(1 To rng.Rows.Count)
i = 1
For Each cell In rng

ary(i) = cell.Font.ColorIndex
i = i + 1
Next cell
CellColours = ary
End Function

and then sum like this to sum all red font cells

=SUMPRODUCT(--(CellColours(A1:A10)=3) ,A1:A10)

and simply count all green font cells like

=SUMPRODUCT(--(CellColours(A1:A10)=10))


--
__________________________________
HTH

Bob

"michelle" wrote in message
...
I'm trying to add the cells who's font color is red. What I have so far is

=SUMIF(F4:F116," ")

Am I close?




Gord Dibben

More Functions based on Font Color
 
How did the font color get to be red?

If by Conditional formatting, Excel won't pick up the colorindex of the
font.

See Chip Pearson's site if that is the case.

http://www.cpearson.com/excel/CFColors.htm


Gord Dibben MS Excel MVP

On Tue, 2 Sep 2008 23:15:01 -0700, michelle
wrote:

I'm trying to add the cells who's font color is red. What I have so far is

=SUMIF(F4:F116," ")

Am I close?




All times are GMT +1. The time now is 04:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com