Count content of cell based on background colour help please

Lensmeister

New Member
Joined
Mar 27, 2006
Messages
45
I have a sheet called "data" and in it there is a range of cells named "players". Some of the cells have a background colour of red (due to being sent off).

On Sheet called "Players" I want a column that counts the number of times a players name has a red background in the data sheet.

For example:

Sheet "Data"
Range "players"


Sheet "Players"
Cell "Z1" has the player name "Jones.J"
in Cell "AA1" I want it to count the number of times "Jones.J" appears WITH a "red" background in the datasheet "data" in the range "players".

Is this possible?
if yes .. How?
Please.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I have a sheet called "data" and in it there is a range of cells named "players". Some of the cells have a background colour of red (due to being sent off).

On Sheet called "Players" I want a column that counts the number of times a players name has a red background in the data sheet.

For example:

Sheet "Data"
Range "players"


Sheet "Players"
Cell "Z1" has the player name "Jones.J"
in Cell "AA1" I want it to count the number of times "Jones.J" appears WITH a "red" background in the datasheet "data" in the range "players".

Is this possible?
if yes .. How?
Please.
I recommend NOT doing it this way.

It's complicated, requires VBA code and it WON'T work the way you think it should work.

If you use a column and put an "X" in it to note when a player is "sent off" then it's a simple matter to count the number of Xs for a player.
 
Upvote 0
I recommend NOT doing it this way.

It's complicated, requires VBA code and it WON'T work the way you think it should work.

If you use a column and put an "X" in it to note when a player is "sent off" then it's a simple matter to count the number of Xs for a player.
Something like this...

Book1
ABCDE
1PlayerSent Off_PlayerSent Off
2Player 5X_Player 52
3Player 1____
4Player 5X___
5Player 1X___
6Player 2X___
7Player 5____
8Player 2____
9Player 2X___
10Player 5____
11Player 2X___
12Player 4____
13Player 1____
14Player 3X___
15Player 3____
Sheet1

One of these formulas entered in E2:

If you're using Excel 2007 or later:

=COUNTIFS(A2:A15,D2,B2:B15,"X")

This one will work in ANY version of Excel:

=SUMPRODUCT(--(A2:A15=D2),--(B2:B15="X"))
 
Upvote 0
There are advantages and disadvantages for each method. I leave it to the user to decide what works best for them. I believe in letting the user decide. Sometimes they like my idea and sometimes not. More solutions means more choices. Hopefully, it is not a Hobson's choice...
 
Upvote 0
There are advantages and disadvantages for each method. I leave it to the user to decide what works best for them. I believe in letting the user decide. Sometimes they like my idea and sometimes not. More solutions means more choices. Hopefully, it is not a Hobson's choice...
Yeah, that's a good position to have but the OP should be made aware of potential unexpected results.
 
Upvote 0
Thanks This is a real help and I am starting to understand what I am doing (well sort of).

The only problem with this is the team line up is held in a row. i.e.

P1, p2, p3 etc.

P1 P2 P3 P4 P5 P6
Dix.J Mallaby.D Curnow.P Campbell.1 Young.P Shears.K
Dix.J Mallaby.D Leng.T Campbell.1 Young.P Shears.K
Hamlet.W Mallaby.D Leng.T Johnson Young.P Bell.W
Hamlet.W Mallaby.D Leng.T Bell. Young.P Johnson.
Hamlet.W Mallaby.D Rogers Hutchinson.F Argyle.N Johnson.
Hamlet.W Mallaby.D Rogers Leng.T Argyle.N Johnson.
Hamlet.W Mallaby.D Rogers Leng.T Argyle.N Bell.W
Hamlet.W Mallaby.D Rogers Rayson Argyle.N Johnson.


eek!!! That never lined up right, but you get my drift.

Now you see what having the "X" at the end would not be prudent. I do already have a formula that shows if there is a red background in a row, but that is so I can do an auto filer to populate a separate sheet.

I have made the full ranges of cells that can have the red background named SendOffs (not original I know) and the players name is in cell P871

Therefore in excel 2002 the formula should be
=SUMPRODUCT(--(ColorIndex(SendOffs)=3),--(SendOffs=P871))

Is this correct?

If so why is it showing #NAME? ?
 
Last edited:
Upvote 0
Thanks This is a real help and I am starting to understand what I am doing (well sort of).

The only problem with this is the team line up is held in a row. i.e.

P1, p2, p3 etc.

P1 P2 P3 P4 P5 P6
Dix.J Mallaby.D Curnow.P Campbell.1 Young.P Shears.K
Dix.J Mallaby.D Leng.T Campbell.1 Young.P Shears.K
Hamlet.W Mallaby.D Leng.T Johnson Young.P Bell.W
Hamlet.W Mallaby.D Leng.T Bell. Young.P Johnson.
Hamlet.W Mallaby.D Rogers Hutchinson.F Argyle.N Johnson.
Hamlet.W Mallaby.D Rogers Leng.T Argyle.N Johnson.
Hamlet.W Mallaby.D Rogers Leng.T Argyle.N Bell.W
Hamlet.W Mallaby.D Rogers Rayson Argyle.N Johnson.


eek!!! That never lined up right, but you get my drift.

Now you see what having the "X" at the end would not be prudent. I do already have a formula that shows if there is a red background in a row, but that is so I can do an auto filer to populate a separate sheet.

I have made the full ranges of cells that can have the red background named SendOffs (not original I know) and the players name is in cell P871

Therefore in excel 2002 the formula should be
=SUMPRODUCT(--(ColorIndex(SendOffs)=3),--(SendOffs=P871))

Is this correct?

If so why is it showing #NAME? ?
The #NAME? error means Excel doesn't recognize one of the names used in the formula.

Chances are it doesn't recognize the name ColorIndex.

Since I don't advocate this method I'll let Kenneth Hobson take it from here.

Good luck!
 
Upvote 0
Thanks Biff.

All help is good help :)

I have had the sheet for years and it functions practically automatically so a change would cause a complete revamp. And I don't have that much hair left on my head for that ... lol
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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