Counting Red Font Cells

johnnyb5

Board Regular
Joined
Dec 23, 2014
Messages
89
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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top