# Counting Red Font Cells

#### johnnyb5

##### Board Regular
I found function instructions to count cells with red fonts and it works fine. (My Thanks to Mike) However, the next step for me is to count the red font cells that are less than the value of 20. I've tried to combine the instructions with both IF and And formulas and both have failed miserably.

The working function is:

Function CountColour(rng As Range, clr As Range)
Application.Volatile
Dim c As Range
For Each c In rng
If c.Font.Color = clr.Font.Color Then
CountColour = CountColour + 1
End If
Next
End Function

The working formula is: (the range of cells is S32:Y45 and the cell color to count is V48)
=CountColour(S32:Y45,V48)

My attempts included several variations of:

=AND(S32:Y45<20, CountColour(S32:Y45,V48))
=IF(S32:Y45<20, CountColour(S32:Y45,V48), "")

Would anyone know how to adjust the function or formula so that I can count the red cells that are less than 20?

### Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a \$25,000 loan, 5% annual interest, 60 month loan.

#### JackDanIce

##### Well-known Member
Perhaps this works? Change in blue:
Rich (BB code):
``````Function CountColour(rng As Excel.Range, clr As Excel.Range) As Long

Dim c As Excel.Range

Application.Volatile

For Each c In rng
If c.Font.Color = clr.Font.Color And c.Value < 20 Then
CountColour = CountColour + 1
End If
Next c

End Function``````

#### johnnyb5

##### Board Regular
Jack,

Just ran the adjusted code and it worked wonderful. I did have to change the name to stop it from conflicting with the original function but both functions work within the same sheet just like I needed!

Great Thanks!!!
JB

You're welcome

Replies
3
Views
69
Replies
3
Views
201
Replies
3
Views
275
Replies
5
Views
425
Replies
6
Views
186

1,127,720
Messages
5,626,475
Members
416,187
Latest member
L_D18

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back