+ Reply to Thread
Results 1 to 9 of 9

Can't make countif return the value I want.

  1. #1
    Registered User
    Join Date
    01-01-2019
    Location
    Depew, NY
    MS-Off Ver
    2019 and 2016
    Posts
    22

    Can't make countif return the value I want.

    I need to check the value of 2 cells based on the counts of 2 ranges. In the attached example I need cells G17 and X17 to both equal 4 if both or one of the counts of ranges (N4:N14) or (AE4:AE14) equal 4. If niether of those ranges equal 4, I need G17 to equal the count of range (N4:N14) and X17 to equal the count of range AE4:AE17. The formula I use in G17 is as follows:

    =IF(AND((COUNTIF($N4:$N14,">0")=4),(COUNTIF($AE4:$AE14,">0")=4)),"4",IF(COUNTIF($AE4:$AE14,">0"=4),"4",COUNTIF($N4:$N14,">0")))

    X17 is similar but the second half of the formula is reversed. The problem is that when I evalutate the forumla, the third countif returns #N/A and I can't figure out why. In the attached sample, both cells G17 and X17 should return a value of 4, but G17 is returning 9. This happens in both formulas. I am using excel 2019 for this spreadsheet mainly, though I do some work with 2016. I hope I explained that well enough.
    Attached Files Attached Files
    Last edited by cayuga306; 02-09-2019 at 12:43 PM. Reason: Corrected Sample

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Can't make countif return the value I want.

    The attached workbook does not match what you are describing. Cell references are wrong. Please update the attachment or your description.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    01-01-2019
    Location
    Depew, NY
    MS-Off Ver
    2019 and 2016
    Posts
    22

    Re: Can't make countif return the value I want.

    Updated the attachment. Thank you for bringing that to my attention.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Can't make countif return the value I want.

    I'm not 100% sure, but you seem to be describing this:

    G17:=IF(OR((COUNTIF($N4:$N14,">0")=4),(COUNTIF($AE4:$AE14,">0")=4)),4,COUNTIF($N4:$N14,">0"))

    X17:=IF(OR((COUNTIF($N4:$N14,">0")=4),(COUNTIF($AE4:$AE14,">0")=4)),4,COUNTIF($AE4:$AE14,">0"))

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,112

    Re: Can't make countif return the value I want.

    You've got a bracket in the wrong place, try
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-01-2019
    Location
    Depew, NY
    MS-Off Ver
    2019 and 2016
    Posts
    22

    Re: Can't make countif return the value I want.

    Both of those answers appear to work. I can't believe I missed the bracket. I looked for that too.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Can't make countif return the value I want.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  8. #8
    Registered User
    Join Date
    01-01-2019
    Location
    Depew, NY
    MS-Off Ver
    2019 and 2016
    Posts
    22

    Re: Can't make countif return the value I want.

    AliGW, I will change to your formula as it is simpler. It's exactly as I stated it in my question. Thank you.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Can't make countif return the value I want.

    You're welcome.

    As I said above, please take a moment to mark the thread as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 8
    Last Post: 05-27-2017, 07:04 AM
  2. I can't make this countif equation work. Help
    By Holden Wright in forum Excel Tips
    Replies: 5
    Last Post: 02-04-2016, 06:30 AM
  3. Make COUNTIF function return blank cell if no data is there
    By jordan1214 in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 04-05-2015, 01:05 PM
  4. how to make countif case sensitive
    By vsbhogar in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-19-2012, 02:02 PM
  5. Count() and CountIf() results don't make sense.
    By foxguy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-13-2012, 04:59 AM
  6. Replies: 18
    Last Post: 06-16-2010, 12:58 AM
  7. How do you make a countif formula with 2 or more critera?
    By Melissa in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-24-2005, 08:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1