CountIF Formula if cell is yellow and has Satisfactory

squeakums

Well-known Member
Joined
May 15, 2007
Messages
851
Office Version
  1. 365
How would I got about writing a countif formula if the cell is yellow and has satisfactory 'text' in it? 2 Factors for count if please?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You can't as a formula can't detect a colour, you either have to test for the condition that the cell is coloured based on or use a VBA function (and even then it depends whether your cell is coloured by fill colour or conditional formatting).
 
Upvote 0
I was trying to use the VBA code on the sheet which I googled and go from there in the countif formula option. Any idea how I would set something like this up to work?
 
Upvote 0
How is the cell coloured with a manual fill or conditional formatting?
 
Upvote 0
Try putting the code below in a regular module, then use the formula below.
Please note that it will only pick up the standard yellow, if they don't use it then we can change the code so that it is based on one of the cells fill color.

Code:
Function ColorFunction(rRange As Range)
    Dim rCell As Range, vResult
    Application.Volatile
    
    For Each rCell In rRange
        If rCell.Interior.ColorIndex = 6 And rCell.Value = "satisfactory" Then vResult = 1 + vResult
    Next rCell

    ColorFunction = vResult
End Function



Book1
ABC
1
2
3
4
53
6satisfactory
7
8
9
10
11
12satisfactory
13satisfactory
14satisfactory
15
16
17
18
Sheet4
Cell Formulas
RangeFormula
C5=ColorFunction(A1:A17)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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