Count contents of cells (by color)

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
I've been reading the forums but haven't found quite what I want.

I have a column of cells that's a mix of green, red, and white colors. I'd like a way to count the contents of all of the green cells, and preferably it needs to auto update every time a cell changes color....so if a cell suddenly becomes green, the user doesn't have to change anything or reselect anything.

Thanks!
 
So to do this, I have the cells changing fill color via conditional formatting.

So I use a formula (=get.cell(38,sheet_reference)) that goes into the name manager under formulas. That formula spits back the color of the cell. I then tried to use SUMIFs to add up all of the cells there were green but it would appear that "get.cell" does not recognize a cell as being green if it was turned green by conditional formatting. It only recognizes cells that were color-changed by the user.
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Well that's where I've gotten stuck again. If I use name manager with get.cell(38,sheet_reference) then I can get it for cells that I fill, but not those that are filled conditionally....so I get stuck.

So I use a formula (=get.cell(38,sheet_reference))
I have never done anything like that before.
Is that the formula you use in your Conditional Formatting rule?
 
Upvote 0
No I use it in Formulas -> name manager and then I can use it in the cells. It just spits out the "color" of the cell, but only returns the value of a cell that I've changed the fill of, not one that conditional formatting has changed. How would you add the contents of cells that were conditionally formatted green?
 
Upvote 0
Like how would you say =sumif(the cell is green, add A1:A3)?
You cannot. Excel formulas only work off of values, not off on formatting.

But if your cells are being colored by conditional formatting, all we have to do is use the same formulas as the criteria in a COUNTIF, COUNTIFS, SUMIF, SUMIFS, or SUMPRODUCT formula to get what you want.

Are we still talking about the same Conditional Formatting rule you posted up in post 7?
Or a different one?
If different, please post the Conditional Formatting rule.

It may also be helpful if you can post a small sample of your worksheet, along with your expected result.
 
Upvote 0
Yes so the conditional formatting is super simple: turn green if =$Q8="Yes"

Then I go to formulas, name manager, and input my (=get.cell(38,sheet_reference))
I then go to a new column (same row) and type in =color which just references the above formula.
If I've manually turned the cell green (which is excel #43), then my =sumifs sums all of my cells in B column that have a "43" in E column. Does that make more sense?

The issue with all of it is that the get.cell piece only works for rows that I change to green manually, not those that change via conditional formatting.
 
Upvote 0
Exactly Get.Cell doesn't pick up colors by conditional format color. I think what Joe is suggesting is you replicate the conditional format rule by COUNTIF(S)/SUMIF(S) where you need, like below. Hope it makes sense, otherwise please upload a sample of data and expected outcome.

Book1
BQ
81Yes
92Maybe
103Yes
114Yes
125Maybe
136
147No
15
16
17Green3
18Red1
Sheet1
Cell Formulas
RangeFormula
Q17Q17=COUNTIF($Q$8:$Q$14,"Yes")
Q18Q18=COUNTIF($Q$8:$Q$14,"No")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B17,B8:B15Expression=$Q8="Yes"textNO
B17,B8:B15Expression=$Q8="No"textNO
 
Upvote 0
Solution
Exactly Get.Cell doesn't pick up colors by conditional format color. I think what Joe is suggesting is you replicate the conditional format rule by COUNTIF(S)/SUMIF(S) where you need, like below. Hope it makes sense, otherwise please upload a sample of data and expected outcome.

Book1
BQ
81Yes
92Maybe
103Yes
114Yes
125Maybe
136
147No
15
16
17Green3
18Red1
Sheet1
Cell Formulas
RangeFormula
Q17Q17=COUNTIF($Q$8:$Q$14,"Yes")
Q18Q18=COUNTIF($Q$8:$Q$14,"No")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B17,B8:B15Expression=$Q8="Yes"textNO
B17,B8:B15Expression=$Q8="No"textNO
Yes, that is exactly what I am telling you to do.
Forget about that other stuff. No need to unnecessarily complicate matters.
 
Upvote 0
Ok this makes a lot more sense than how I was doing it! Thank you both. This cleaned up my sheet a lot! Thanks guys!
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,476
Members
448,967
Latest member
visheshkotha

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