Forum Discussion
Can someone help me create the correct formula
Hi. I need help getting the formula correct. I need to count the number occurrences of blue, green, purple, and blank cells. Am I even using the right function? If the function is right, what am I entering wrong?
Please help me - I'm only mediocre in Excel and need guidance!
Here's the formula that's in the cell: COUNTIF(d2:d12(d2:d12=”purple”)+(d2:d12=”green”)+(d2:d12=”blue”))
2 Replies
- Mayukh_BhattacharyaIron Contributor
BeckyBo334 it will be helpful, if you read the MSFT Documentations once before applying the function. However, you could use one of the followings, also instead of hardcoding the colors count needed place them in some range and use it as a reference like shown below.
Using COUNTIF() , SUM() & HSTACK()
=SUM(COUNTIF(D2:D12,HSTACK("blue","green","purple","")))
Or, Color refers to range F6:F8 (you may need to change the cell range as per your suit)
=SUM(COUNTIF(D2:D12,Color))
Use a combination of SUM and COUNTIF:
=SUM(COUNTIF(D2:D12, {"blue", "green", "purple"}))
If you also want to count blank cells in the range:
=SUM(COUNTIF(D2:D12, {"blue", "green", "purple", ""}))