Trying to count cells that meet more than one Criteria

suziq729

New Member
Joined
Jul 15, 2005
Messages
8
Help! I have been trying to get a total of cells where they contain "Y" AND have a certain fill color. Nothing I've tried is working. Here are the formulas that have not worked so far. Any ideas??

=COUNT((E9:E491="Y")*(countcolor(B4,E9:E491))*E9:E491)

=COUNT((E9:E491="Y"),((countcolor(B5,E9:E491))))

=COUNT((E9:E491="Y")+((countcolor(B4,E9:E491))))

Thanks...Sue
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Also, I was not using count at all....please look at the formula above including SUMPRODUCT - that is the closest I have gotten thus far, but it returns "0" every time...
 
Upvote 0
suziq729 said:
Ok...I think I am getting closer, but it is now returning "0" every time. Here is what I entered after copying the code into Editor:

=SUMPRODUCT(--(ExtCell("backgroundcolor",D9:D482,1)=B5),--(D9:D482="Y"))

Where B5 is filled with the desired color. I think that might be where I am going wrong?

What do you have in B5 - an integer?
 
Upvote 0
No...I only have the cell filled with a color....I thought the countcolor formual I had would recognize it. That formula is:

Function CountColor(ColorRange As Range, Target As Range) As Long
Dim c As Range
For Each c In Target
If c.Interior.ColorIndex = ColorRange.Interior.ColorIndex Then
CountColor = CountColor + 1
End If
Next
End Function

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub
 
Upvote 0
suziq729 said:
No...I only have the cell filled with a color....I thought the countcolor formual I had would recognize it. That formula is:

Function CountColor(ColorRange As Range, Target As Range) As Long
Dim c As Range
For Each c In Target
If c.Interior.ColorIndex = ColorRange.Interior.ColorIndex Then
CountColor = CountColor + 1
End If
Next
End Function

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub


So, the exhibit I posted is not what you're looking for?
 
Upvote 0
Aladin,

I'm intrigued by the code you posted from Harlan Grove. However, I've been unable to get it to work for me in this context

=IF(ExtCell("backgroundcolor",A3:A9)=B4,"yes","no")

The formula returns no, which is false, because the colors are indeed the same. I've also tried it with just A3 being equal to B4. I would like to know how to utilize this function (which, BTW, I think is great--thanks for sharing!).

Any further comments on this function would be greatly appreciated.

Thanks
wally
 
Upvote 0
poorwallace said:
Aladin,

I'm intrigued by the code you posted from Harlan Grove. However, I've been unable to get it to work for me in this context

=IF(ExtCell("backgroundcolor",A3:A9)=B4,"yes","no")

The formula returns no, which is false, because the colors are indeed the same. I've also tried it with just A3 being equal to B4. I would like to know how to utilize this function (which, BTW, I think is great--thanks for sharing!).

Any further comments on this function would be greatly appreciated.

Thanks
wally

You need to read the comments accompanying the code... Since you feed a range to ExtCell, the function must be informed that you want to return an array like in:

=IF(OR(ExtCell("backgroundcolor",A3:A9,1)=B4),"yes","no")

or simply...

=IF(ISNUMBER(MATCH(B4,ExtCell("backgroundcolor",A3:A9,1),0)),"yes","no")
 
Upvote 0
Hi,

Another option,
Example2.xls
BCDEFG
2y63
3n3
4y3Color=GET.CELL(38,Sheet2!$B4)
5y6
6n3
7y3
8y6
9y3
10n3
Sheet2


Defined Color as

=GET.CELL(38,Sheet2!$B2)

Formula in E2,

=SUMPRODUCT(--(C2:C10=6),--(B2:B10="y"))

HTH
 
Upvote 0

Forum statistics

Threads
1,223,919
Messages
6,175,368
Members
452,638
Latest member
Oluwabukunmi

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