+ Reply to Thread
Results 1 to 14 of 14

sum non adjacent cells with multiple count criteria

  1. #1
    Registered User
    Join Date
    09-03-2010
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    19

    sum non adjacent cells with multiple count criteria

    Hi,

    My question relates to the thread below:
    http://www.excelforum.com/excel-work...ent-cells.html

    Could someone tell me how I could construct a single formula which counts non-adjacent cells and has more than one count criterion. I've tried doing this by summing multiple SUMPRODUCTs, but the formula becomes way too long.

    Thanks

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: sum non adjacent cells with multiple count criteria

    Your link to the other sheet includes some simple effective answers. They should suffice. Next step would be SUMPRODUCT(). This, too, should suffice. Without better information we can't suggest anything more.

    Click GO ADVANCED and use the paperclip icon to post up a desensitized copy of your workbook. In it, mockup a sample set of "results" so we can see what you're trying to accomplish, make sure your criterion are fully explained as well. I'm sure we can help from there.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-03-2010
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: sum non adjacent cells with multiple count criteria

    OK,

    I've included a simple example.

    Basically, without reorganising the data, I want to count the number of girls who are in team A or B. So I want to count the cells in the team column for the letters A or B but getting excel to add to the count only if the letters correspond to a girl member.

    Sorry, before I just wanted to count every other (even) cell, but I've made the cells which need counting random in this example.

    Many thanks!
    Attached Files Attached Files

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

    Re: sum non adjacent cells with multiple count criteria

    Excel does not know if "Dana" is a girl or a boy.

    To sum up only the girls' scores, you need to identify if the person is a girl or a boy.

    See attached for how this can work with an additional column denoting the gender (presuming I have the name-to-gender mapping correct).

    Of course, with the gender column in place, the most efficient way would be to build a pivot table instead of using formulae. I've inserted a pivot table as well, so you can see how it looks.

    cheers
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-03-2010
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: sum non adjacent cells with multiple count criteria

    Hi,

    Thanks, but I wanted this calculation to be embedded as the logic in an IF calculation, so I would prefer not to use pivot tables. I was looking for something a little neater and won't appear on the spreadsheet, like:

    =COUNTIF(in range: A1,A3,A5:A6 with criteria "A" or "B")

    (sorry about the abuse of formula, but I thought it would be easier for you to understand what I wanted).

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

    Re: sum non adjacent cells with multiple count criteria

    icylemontea,

    You can want all you want, but tell me, how will Excel know if a name is a girl or a boy if you don't provide that information?

    In the file I attached above I have given you a pivot chart option.

    I have also given you a formula solution.

    But the core issue remains: you need to identify the gender of the name.

    You have two solutions. Choose the one that suits you best.

    Or am I not getting something here?

  7. #7
    Registered User
    Join Date
    09-03-2010
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: sum non adjacent cells with multiple count criteria

    Sorry, I've probably confused things.
    The gender thing was only an example I was using. What I meant was if I wanted the count range to be specific cells, say cells (B2:B5,B7:B8), with some nonadjacent.
    So with the gender example in the attachment, I would want the count range to be (B4,B6:B7,B9), since these are the cells which correspond to girls. I.e, I want to select the count range manually rather than finding a way to make excel recognise the cells corresponding to girls automatically by adding an extra column.

    Hope that has made it clearer.
    I really appreciate your help.

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

    Re: sum non adjacent cells with multiple count criteria

    The gender is just one example of a secondary criterion to sum data.

    Your original data has only name and value. If you want to sum the values based on something other than name, then you will have to provide the criterion in the data.

    Again, the gender is just an example. You could as well use eye color or shoe size. The point is, that if your data is just name-value, you can not summarize any other criterion. You need to include it in the data.

    I have given you a method to provide another criterion and sum by that.

    Use it.

  9. #9
    Registered User
    Join Date
    09-03-2010
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: sum non adjacent cells with multiple count criteria

    I have to be able to randomly choose the cells I want to include in the count range. eg if I only wanted to include a specific 5 out of 10 girls in the count rather than all 10, the method you provided won't work in this case since it will count all the girls.

    What I meant in the previous post is I want to forget column A (the name column) completely.
    Let's say I have only one column in my table with the letters A-F of the alphabet placed randomly in each cell of that column and I want to count the number of cells in certain nonadjacent parts of that column containing either A or B. How would I do that?

    Thanks.

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: sum non adjacent cells with multiple count criteria

    Referring back to the thread you first referenced and adapting:

    Please Login or Register  to view this content.
    If that's still not what you need post a sample that does reflect your exact requirements.

    As you've seen providing hypothetical scenarios is unlikely to benefit - in XL the specifics generally matter.

  11. #11
    Registered User
    Join Date
    09-03-2010
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: sum non adjacent cells with multiple count criteria

    Thank You!

  12. #12
    Registered User
    Join Date
    11-20-2011
    Location
    Tehran
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question Re: sum non adjacent cells with multiple count criteria

    It seems that the below formula works well for a criteria such as "A" or "B"...

    =SUM(COUNTIF(INDIRECT({"B1:B2","B5","B8:B23"}),"A"),COUNTIF(INDIRECT({"B1:B2","B5","B8:B23"}),"B"))

    But, it dose not work for a numeric criteria e.g. 3

    I would be grateful if you give me your guidance ASAP.

  13. #13
    Registered User
    Join Date
    11-20-2011
    Location
    Tehran
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: sum non adjacent cells with multiple count criteria

    The problem was solved...

    It seems the mentioned formula doesn't work without SUM...
    I mean for example you have to use SUM like below if you want to have just ONE criteria:
    SUM(COUNTIF(INDIRECT(.....),....) , 0)

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

    Re: sum non adjacent cells with multiple count criteria

    Welcome to the Forum, hessamhoor. Unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

+ 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