Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2012, 02:26 AM
Algo Algo is offline Countifs and Sumproduct Windows Vista Countifs and Sumproduct Office 2007
Novice
Countifs and Sumproduct
 
Join Date: Nov 2012
Posts: 3
Algo is on a distinguished road
Default Countifs and Sumproduct

Can Countifs and Sumproduct work together?
I have a column I4:I80. In this column, all the cells have either text "NF" or "F". Some of these cells are coloured light grey and some are not. I want to have a formula that will count the number of NF or F that are only in the light grey cells.

This is the formula I used for counting the number of "F" :



=countifs(I4:I80,"=F", I4:I80,"=sumproduct(--(colorindex(I4:I80)=colorindex(I87)))")

I87 is the cell where I have the light grey colour highlighted for reference.

Why does the formula return a 0 (zero) for both NF and F? (I have 20 NF and 8 F in light grey coloured cells.)

Attached is the function for colorindex.

Can anyone help? Thank you
Attached Files
File Type: docx ColorIndex Function.docx (12.0 KB, 9 views)

Last edited by Algo; 11-08-2012 at 05:14 AM. Reason: Mistake in the above countifs formula
Reply With Quote
  #2  
Old 11-08-2012, 08:19 PM
macropod's Avatar
macropod macropod is online now Countifs and Sumproduct Windows 7 64bit Countifs and Sumproduct Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It might make things easier if you could attach the workbook concerned, with some sample data (delete anything sensitive).

FWIW, it seems to me that, as coded, your formula couldn't possibly work, as:
=countifs(I4:I80,"=F", I4:I80,"=sumproduct(--(colorindex(I4:I80)=colorindex(I87)))")
says the third expression has to be, not the calculated result, but the literal string:
"=sumproduct(--(colorindex(I4:I80)=colorindex(I87)))"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-09-2012, 12:25 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Countifs and Sumproduct Windows 7 64bit Countifs and Sumproduct Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,770
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Is the coloring of the cells the result of some Conditional Formatting?
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #4  
Old 11-10-2012, 11:33 PM
Algo Algo is offline Countifs and Sumproduct Windows Vista Countifs and Sumproduct Office 2007
Novice
Countifs and Sumproduct
 
Join Date: Nov 2012
Posts: 3
Algo is on a distinguished road
Default Using countifs with sumproduct

Thanks for the reply, Macropod. I've attached an excel file that contains some formulae that I used, including the countifs and sumproduct together. Please see if there is another way to solve the problem. Many thanks.

Thanks Pecoflyer for the reply too. No, I just colored the cell for identification. No special formatting.

Attached Files
File Type: xlsm countifssumproduct.xlsm (24.7 KB, 11 views)
Reply With Quote
  #5  
Old 11-11-2012, 05:42 AM
Catalin.B Catalin.B is offline Countifs and Sumproduct Windows Vista Countifs and Sumproduct Office 2010 32bit
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

Hi Algo,
This function has some problems:
=COUNTIFS(A6:A25;"=F"; A6:A25;"=SUMPRODUCT(--(colorindex(A6:A25)=colorindex(D6))")
If you put this criteria like this: "=SUMPRODUCT(--(colorindex(A6:A25)=colorindex(D6))",
the function will check if the provided range contains the text between "".
Obviously, you want the criteria to be the result of Sumproduct function. For this, the criteria should look like: (without "" and equal sign):
SUMPRODUCT(--(colorindex(A6:A25)=colorindex(D6))
Another problem is that the result of Sumproduct function is a number: 11 in your case...which means that you count in that range, the cells that contains the number 11. Again, it's obvious that there is no number in that range... so the result is zero.
Your formula should look like:
=COUNTIFS(A6:A25;"=F";colorindex(A6:A25);colorinde x(D6))
But the problem is that COUNTIFS function does not accept this type of range: colorindex(A6:A25), so it will fail...
You have more than 2 options:
-use this formula: =SUM(IF((A6:A25="F")*(colorindex(A6:A25)=colorinde x(D6));1)) confirmed with CSE
-use this formula:
=COUNTIFS(A6:A25;"=F";C6:C25;colorindex(D6)), after you use in C6:C25 the formula colorindex(A6) copied down to extract the color index of range A6:A25
-another option is to wait for a better solution
Reply With Quote
  #6  
Old 11-13-2012, 05:48 AM
Algo Algo is offline Countifs and Sumproduct Windows Vista Countifs and Sumproduct Office 2007
Novice
Countifs and Sumproduct
 
Join Date: Nov 2012
Posts: 3
Algo is on a distinguished road
Default Countifs and Sumproduct

Hi Catalin B. I agree with you and Macropod that "=SUMPRODUCT(--(colorindex(A6:A25)=colorindex(D6))" will not give a result as a number in this case. Hence I made changes so that "Sumproduct" need not be used. Attached is the same file with the changes made.
Thanks for all the suggestions given.
Attached Files
File Type: xlsm countifssumproduct.xlsm (25.8 KB, 9 views)
Reply With Quote
  #7  
Old 11-13-2012, 07:44 AM
Catalin.B Catalin.B is offline Countifs and Sumproduct Windows Vista Countifs and Sumproduct Office 2010 32bit
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

Quote:
Originally Posted by Catalin.B View Post
-use this formula: =SUM(IF((A6:A25="F")*(colorindex(A6:A25)=colorinde x(D6));1)) confirmed with CSE
-use this formula:
=COUNTIFS(A6:A25;"=F";C6:C25;colorindex(D6)), after you use in C6:C25 the formula colorindex(A6) copied down to extract the color index of range A6:A25
I guess you did not read the entire message, so your efforts are in vain...
I gave you a replacement for your formula that will do the job. It's the one in red, in case you don't read this message
Reply With Quote
Reply

Tags
colorindex, countifs, sumproduct

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
sumproduct?? jer Excel 9 10-14-2012 10:00 AM
Countifs and Sumproduct Sumproduct formula Portucale Excel 2 09-12-2012 10:51 AM
Match Index with sumproduct/vlookup angie.chang Excel 1 06-18-2012 08:47 AM
Countifs and Sumproduct Sumproduct angie.chang Excel 3 06-14-2012 10:00 AM
countifs? sonyaturpin Excel 1 05-23-2012 08:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:58 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft