+ Reply to Thread
Results 1 to 8 of 8

Using IF and COUNTIF together

  1. #1
    Registered User
    Join Date
    02-14-2011
    Location
    Muscatine, Iowa
    MS-Off Ver
    Excel 2010
    Posts
    30

    Using IF and COUNTIF together

    I have this formula working for just the one cell but I would like it to work for everything the the column from A24:A1500 and J24:J1500. But for some reason when I change it to a range it errors out.

    I'm using Office 2010

    PHP Code: 
    =IF(A24="Atlanta"COUNTIF(J24,"Bankrupt"),0

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Using IF and COUNTIF together

    Try something like this:

    =SUMPRODUCT((A24:A1500="Atlanta")*(J24:J1500="Bankrupt"))

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Using IF and COUNTIF together

    Ron's method is better, in my opinion, but the formula to use if you wanted to continue using COUNTIF and IF would be

    =COUNTIF(IF(A24:A1500="Atlanta", J24:J1500),"Bankrupt")
    (Note: Confirm with CTRL+SHIFT+ENTER, not just ENTER)

    For more information on SUMPRODUCT, I recommend reading this article:
    http://xldynamic.com/source/xld.SUMPRODUCT.html

  4. #4
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Using IF and COUNTIF together

    Oops. I forgot COUNTIF doesn't work with Arrays.

    =SUM(IF(IF(A24:A1500="Atlanta", J24:J1500)="Bankrupt",1,0))
    Confirmed with CTRL+SHIFT+ENTER

  5. #5
    Registered User
    Join Date
    02-14-2011
    Location
    Muscatine, Iowa
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Using IF and COUNTIF together

    Ron's works great. I tried the COUNTIF but ran into problems.

    Is there a way to put a range in like Atlanta, Dallas, Brazil, Cedar Rapids in as a range to count?

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Using IF and COUNTIF together

    How about...

    =SUMPRODUCT((A24:A1500={"Atlanta","Dallas","Brazil","Cedar Rapids"})*(J24:J1500="Bankrupt"))
    HTH
    Regards, Jeff

  7. #7
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Using IF and COUNTIF together

    Quote Originally Posted by extremecorvette View Post
    I'm using Office 2010
    Use COUNTIFS, which is faster than SUMPRODUCT.

    =SUM(COUNTIFS(A:A,{"Atlanta","Dallas","Brazil","Cedar Rapids"},J:J,"Bankrupt"))

    Or, enter all the Keywords in a range & use like,

    =SUMPRODUCT(COUNTIFS(A:A,Keyword_Range,J:J,"Bankrupt"))
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  8. #8
    Registered User
    Join Date
    02-14-2011
    Location
    Muscatine, Iowa
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Using IF and COUNTIF together

    It works thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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