+ Reply to Thread
Results 1 to 3 of 3

CountIf Function for two Columns

  1. #1
    Forum Contributor
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    292

    CountIf Function for two Columns

    I am using the following formula(s) to calculate different criteria entered into two different columns - for example the user would either type Blue or Red into column H and Shirts or Pants into column J:

    =COUNTIF(H2:H24,"Blue")
    =COUNTIF(H2:H24,"Red")

    =COUNTIF(J2:J24,"Shirts")
    =COUNTIF(J2:J24,"Pants")

    Now I need to calculate a combination of those two columns. For instance, how would the formula be written if the cell was to produce a number for the combination of blue shirts entered? Or, blue pants, red pants... etc.

    Thank you!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: CountIf Function for two Columns

    =sumproduct((H2:H24="Blue")*(J2:J24="Shirts")) would do it
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

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

    Re: CountIf Function for two Columns

    Is your profile accurate? Excel 2000?

    Try

    =SUMPRODUCT(--(H2:H24="Blue"),--(J2:J24="Shirts"))

    or you can use a cell to create the reference...

    =SUMPRODUCT(--(H2:H24=H1),--(J2:J24=J1))

    If you have 2007+
    =COUNTIFS(H2:H24,"Blue",J2:J24,"Shirts")

    =COUNTIFS(H2:H24,H1,J2:J24,J1)
    HTH
    Regards, Jeff

+ 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