Count occurrences and returns color

New Contributor


Can anyone help me with a formula or a VBA script ?
There are 4 columns with many possible choices (Alice,Bob,Clarisse,Denis,Ernest...). The whole idea is to let 4 teams (columns) to pick a name as representative and check if they do agree on a name or not
I would like to count the number of name and return a color.
For instance, if in a row, there are 4 "Alice" or 3 "Alice", it should return green color cell
IF there are only 2 "Alice", it returns orange color cell
To finish with, if a row contains less that one "Alice", it will return a red color cell.

I tried some formulas with "IF" and "CountIF", but cannot apply it to the whole sheet since the names are all different (mostly names).




The colored cell goes to the corresponding row from the table "Result"

Thanks in advance

4 Replies


Should this be specific for Alice, or do you want to color a cell green if any name gets 3 or 4 votes?

@Hans Vogelaar 


Hello !

Yes this is not specific to Alice but any name since there are 33 different names.



Let's say  that the choices are in columns A to D, starting in row 2 and that you want to color F2 and down.

Select the range in column F that you want to format. F2 should be the active cell in the selection.

On the Home tab of the ribbon, select Conditional Formatting > New Rule...

Select 'Use a formula to determine which cells to format'.

Enter the formula




Click Format...

Activate the Fill tab.

Select green.

Click OK, then click OK again.


Repeat these steps, but with the formula




and orange.

Finally, repeat them again with the formula




and red.

Thanks a lot, i will try it out !