I created the following user defined function:
Function FontColor(r As Range) As Integer
FontColor = r.Font.ColorIndex
End Function
Now I need to count only the rows that have "cat" in column A as well as red font in column B:
<tbody>
</tbody>
The formula I'm using is this:
{=COUNT(IF(A:A="cat",IF(fontcolor(B:B)=3,B:B)))}
This tells excel to count the rows in column B, only when the left column is "cat" and the right column has a red font. But it's not working. I get the answer "0". However if I replace the user defined formula with a "built-in" one like this:
{=COUNT(IF(A:A="cat",IF(SQRT(B:B)=3,B:B)))}
The formula works well, I get the answer "2". This tells me that somehow user-defined functions don't work within array formulas, OR they need to be modified to work within array formulas.
Any suggestions, or comments?
Function FontColor(r As Range) As Integer
FontColor = r.Font.ColorIndex
End Function
Now I need to count only the rows that have "cat" in column A as well as red font in column B:
A | B |
dog | 8 |
cat | 9 |
shoe | 6 |
cat | 9 |
shoe | 42 |
dog | 8 |
cat | 7 |
<tbody>
</tbody>
The formula I'm using is this:
{=COUNT(IF(A:A="cat",IF(fontcolor(B:B)=3,B:B)))}
This tells excel to count the rows in column B, only when the left column is "cat" and the right column has a red font. But it's not working. I get the answer "0". However if I replace the user defined formula with a "built-in" one like this:
{=COUNT(IF(A:A="cat",IF(SQRT(B:B)=3,B:B)))}
The formula works well, I get the answer "2". This tells me that somehow user-defined functions don't work within array formulas, OR they need to be modified to work within array formulas.
Any suggestions, or comments?