+ Reply to Thread
Results 1 to 13 of 13

Countif with AND formula

  1. #1
    Forum Contributor
    Join Date
    02-29-2012
    Location
    UK, Newcastle
    MS-Off Ver
    Office 365
    Posts
    130

    Countif with AND formula

    Hi All, I have the following simple formula in a cell on another tab of a worksheet. Unfortunately it is returning a #VALUE! error.
    =COUNTIF(Engineering!G:G,"ecn")*AND(Engineering!I:I,"yes")
    The part prior to *AND works fine on its own.

    The aim is to have the countif part only count if there is a cell in the same row in the I column with yes in it.

    Can anyone advise where I am going wrong?

    I will also be adding a third part which check another cell in the same row has a date matching a date in cell a1.

    thanks

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Countif with AND formula

    Try the countifS function

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Countif with AND formula

    Like this

    =COUNTIFS(Engineering!G:G,"ecn",Engineering!I:I,"yes")
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Forum Contributor
    Join Date
    02-29-2012
    Location
    UK, Newcastle
    MS-Off Ver
    Office 365
    Posts
    130

    Re: Countif with AND formula

    Many thanks guys, The one from Alkey worked a treat. Now i will attempt to add a date reference also.
    thanks again.

  5. #5
    Forum Contributor
    Join Date
    02-29-2012
    Location
    UK, Newcastle
    MS-Off Ver
    Office 365
    Posts
    130

    Re: Countif with AND formula

    struggling a little with the date part.

    I am looking to have another cell in column H checked to make sure the date falls in the range i require.
    So in cell A1 i will enter 04/2014 which will format to Apr-14 I then need to add to the above formula to check that the date cell in the same row has a date that falls in April 2014. The format of the date is currently dd/mm/yyyy.

    Again any help is really appreciated.
    thanks

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Countif with AND formula

    Are you trying to use date as another criteria for the formula above? If yes, here is how date should be presented when used as criteria in COUNTIF(s) formulas:

    if the date is hard-coded:

    =COUNTIF(A:A,">=1/1/2014") is when the date is equal or greater

    If your criteria is in the cell then use this:

    =COUNTIF(A:A,">="&B1)

  7. #7
    Forum Contributor
    Join Date
    02-29-2012
    Location
    UK, Newcastle
    MS-Off Ver
    Office 365
    Posts
    130

    Re: Countif with AND formula

    Hi Yes, trying to include it in same formula. So now I have the following =COUNTIFS(Engineering!G:G,"ecn",Engineering!I:I,"yes",Engineering!H:H,">="&B1).
    Hopefully this will only count if the cells are equal to ECN, Yes and fall in the month of the date I enter into B1.
    Yes its working as I hoped.

    Many thanks Alkey, I would truly buy you a pint if I could.

  8. #8
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Countif with AND formula

    Glad I could help

  9. #9
    Forum Contributor
    Join Date
    02-29-2012
    Location
    UK, Newcastle
    MS-Off Ver
    Office 365
    Posts
    130

    Re: Countif with AND formula

    Ahhh, just spotted another problem. The date is choosing equal to or bigger than the date I enter. If I try and recall the data for say January this year then it counts from January onwards.
    I removed the > and thought this to be working for a while but now know it is because I was using test data with a date of 01/01/2014 or 01/02/2014 Etc. When I add the date to the date search cell as 01/2014 for January 2014 it actually records a date of 01/01/2014 instead of simply 01/2014 as in mm/yyyy. I formatted the cell as mm/yyyy thinking this would work but alas not. I will tinker with the date formats and try to have the data store as 01/2014 for month/year. But then unsure if the count will work as I need the date to be based on any day of the given month and year.

  10. #10
    Forum Contributor
    Join Date
    02-29-2012
    Location
    UK, Newcastle
    MS-Off Ver
    Office 365
    Posts
    130

    Re: Countif with AND formula

    Any thoughts on this one?

  11. #11
    Forum Contributor
    Join Date
    12-19-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Countif with AND formula

    Even if you format the date as mm/yyyy it will still be stored as the exact day it was entered. You'll need to make another column to get the month. Use the following formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    A1 refers to the cell that has your date in it. Your SUMIFS should refer to the cell with the formula in it. Let me know if it works.

  12. #12
    Forum Contributor
    Join Date
    02-29-2012
    Location
    UK, Newcastle
    MS-Off Ver
    Office 365
    Posts
    130

    Re: Countif with AND formula

    Hi, I still want the date in my original cell to be an exact date. So I could add another column next to the date column in my original sheet and add your suggested formula. This would convert all the dates to the first of the same month, then i could use my previous formula the way it was as this is already using the same date format?
    I will try this but would rather not add in an extra column, I would rather have the formula altered to pull this data out as required.

    many thanks

  13. #13
    Forum Contributor
    Join Date
    12-19-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Countif with AND formula

    Could you not hide the column that you create? You can work the formula I gave you into the countif but it'd probably have to become an array as it has to operate on each item in the column you've specified and I'm not that good!

    Thanks

+ 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. CountIf formula results in the formula itself being displayed.
    By NewKid in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-19-2017, 03:31 PM
  2. [SOLVED] Using Countif formula on cells that have a Left formula
    By fsoares22 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-10-2013, 11:13 AM
  3. [SOLVED] =Subtotal(countif,Range); Subtotal and countif in 1 formula [SOLVED]
    By thomas.mapua in forum Excel General
    Replies: 5
    Last Post: 01-06-2012, 11:33 AM
  4. Adding a CountIF to a formula that is already Countif
    By Cmorgan in forum Excel General
    Replies: 4
    Last Post: 06-01-2011, 09:34 AM
  5. #value! for the formula countif
    By chinsian.chen in forum Excel General
    Replies: 5
    Last Post: 05-27-2009, 05:50 AM

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