+ Reply to Thread
Results 1 to 13 of 13

Excel 2007 : Count or Countif?

  1. #1
    Registered User
    Join Date
    09-18-2011
    Location
    SW FL
    MS-Off Ver
    Excel 2007
    Posts
    15

    Question Count or Countif?

    I have attached an example of a spreadsheet whereby I am trying to count the number of "x's" in Column B based upon the "department" in Column A. I have tried the Count, CountIf and CountIfs functions but cannot get it to work. Do I have to be concerned about how the cells are formatted? Can anyone provide with me a solution?

    Example.xlsx
    Last edited by thomcatbob; 09-24-2011 at 11:02 PM.

  2. #2
    Registered User
    Join Date
    09-10-2011
    Location
    TRICHY INDIA
    MS-Off Ver
    Excel 2007
    Posts
    57

    Smile Re: Function to use in Excel 2007? Count or Countif?

    Quote Originally Posted by thomcatbob View Post
    i have attached an example of a spreadsheet whereby i am trying to count the number of "x's" in column b based upon the "department" in column a. I have tried the count, countif and countifs functions but cannot get it to work. Do i have to be concerned about how the cells are formatted? Can anyone provide with me a solution?

    Attachment 121763
    just use the pivot table option
    you will get the result.

  3. #3
    Valued Forum Contributor
    Join Date
    05-23-2011
    Location
    Lahore PK
    MS-Off Ver
    Excel 2007, 2013
    Posts
    627

    Re: Function to use in Excel 2007? Count or Countif?

    see attatchment

    is it what you need?
    Attached Files Attached Files
    Azam
    If you want to say Thank you to a member, click the reputation icon (Star) in the left bottom of the post.
    For prompt answer, be descriptive, concise, short, direct, and to-the-point.

  4. #4
    Registered User
    Join Date
    09-18-2011
    Location
    SW FL
    MS-Off Ver
    Excel 2007
    Posts
    15

    Unhappy Re: Function to use in Excel 2007? Count or Countif?

    Quote Originally Posted by Azam Ali View Post
    see attatchment

    is it what you need?
    You obtained the correct answer for Day 1, but I copied the function into my spreadsheet and tried to total by day 1 and 2. I obtained the correct result for day 1 but day 2 was incorrect. Please note each column represents a day and the number of 'x's' by dept are going to be different.

    Did I copy and paste incorrectly?

    Here's my spreadsheet with your function:
    Attached Files Attached Files

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Function to use in Excel 2007? Count or Countif?

    The formula does not look at either column B or C. The fact that it counts correctly for day 1 is pure coincidence, since day 1 has x values in all rows.

    Use this in B14 instead

    =SUMPRODUCT(--(--LEFT($A$2:$A$11,1)=$A23),--(B$2:B$11="x"))

    copy down and across.

  6. #6
    Registered User
    Join Date
    09-18-2011
    Location
    SW FL
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Function to use in Excel 2007? Count or Countif?

    Thanks teylyn - it performs the function I needed!!!

    Can you explain how it works? I understand most of the function except the --LEFT - what does this mean?

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Function to use in Excel 2007? Count or Countif?

    Hi,

    =left(<cell>,n)

    takes returns the a string of n characters from a text string in <cell>, starting from the left. The -- before the Left is a typo, which I did not notice when I copied the formula. But it does no harm, so the formula still works.

  8. #8
    Registered User
    Join Date
    09-18-2011
    Location
    SW FL
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Function to use in Excel 2007? Count or Countif?

    The solution provided by "teylyn" answered my question for counting the "x's" in each column. Now I'm trying to figure out how to "count" the "x's" across the rows, e.g. Total E2 = number of "x's" in Columns B-D. Since I'm using an "x", the function count and sum aren't working since it's not a number.
    Attached Files Attached Files

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Function to use in Excel 2007? Count or Countif?

    Hello,

    in E2

    =COUNTIF(B2:D2,"x")

    copy down.

    cheers,

  10. #10
    Registered User
    Join Date
    09-18-2011
    Location
    SW FL
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Function to use in Excel 2007? Count or Countif?

    Thanks teylyn for your responses - they have worked like a charm.

    My requirements have changed a bit - I've had to add a column and need to total the "x' values by Breakfast (b) and Lunch (L). Attached is the sample worksheet.

    Anyone have any suggestions?
    Attached Files Attached Files

  11. #11
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Count or Countif?

    How about:
    Attached Files Attached Files
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  12. #12
    Registered User
    Join Date
    09-18-2011
    Location
    SW FL
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Count or Countif?

    ConneXionLost - thank you, it worked.

    Now, I'm trying to get the grand totals by columns B&L utilizing the numbers rather than the 'x's'. Would I use a variation of that formula? I'm still grappling with the SUMPRODUCT function.

  13. #13
    Registered User
    Join Date
    09-18-2011
    Location
    SW FL
    MS-Off Ver
    Excel 2007
    Posts
    15

    Lightbulb Re: Count or Countif?

    I think I got it!!!!

    =SUMPRODUCT(--(($C$4:$AP$4)=AQ$4),--($C23:$AP23))

    Many thanks to everyone who have helped out on these functions!

+ 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