# Thread: CountIF Formula if cell is yellow and has Satisfactory Thanks: 0 Likes: 0

1. ## CountIF Formula if cell is yellow and has Satisfactory

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?  Reply With Quote

2. ## Re: CountIF Formula if cell is yellow and has Satisfactory

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).  Reply With Quote

3. ## Re: CountIF Formula if cell is yellow and has Satisfactory

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?  Reply With Quote

4. ## Re: CountIF Formula if cell is yellow and has Satisfactory

How is the cell coloured with a manual fill or conditional formatting?  Reply With Quote

5. ## Re: CountIF Formula if cell is yellow and has Satisfactory

It's colored manually by another group.  Reply With Quote

6. ## Re: CountIF Formula if cell is yellow and has Satisfactory

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```

ABC
1
2
3
4
53
6satisfactory
7
8
9
10
11
12satisfactory
13satisfactory
14satisfactory
15
16
17
18

Sheet4

Worksheet Formulas
CellFormula
C5=ColorFunction(A1:A17)  Reply With Quote

## User Tag List

#### Tags for this Thread

cell, countif, formula, satisfactory, yellow #### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•