+ Reply to Thread
Results 1 to 21 of 21

Count the number of shared names by other groups

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Count the number of shared names by other groups

    Dear all,

    I made an example here for my problem. There are 4 groups in columns A:D, which are named as G_1, G_2, G_3, G_4.

    In cell G1, I use the formula below to calculate the number of names in group G_1 that are also exist in group G_2:

    Please Login or Register  to view this content.
    Now my question is: how to find the number of names that are shared by ALL OTHER groups (i.e. not just a group)?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Count the number of shared names by other groups

    I think:
    =SUM(IF(COUNTIF(B2:B8,A2:A8)>0,1,0)*IF(COUNTIF(C2:C8,A2:A8)>0,1,0)*IF(COUNTIF(D2:D8,A2:A8)>0,1,0))
    as an array formula (confirm with ctrl+shift+enter) would give you the number of names in all four groups.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    Hi ragulduy, is there a way to use the named ranges? I tried something like:

    Please Login or Register  to view this content.
    But it did not work.

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    Is there any one who can provide a nice answer? My former formula does not work

    Thanks in advance.

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Count the number of shared names by other groups

    =SUM(IF(COUNTIF(INDIRECT(F2),INDIRECT(F1))>0,1,0)*IF(COUNTIF(INDIRECT(F3),INDIRECT(F1))>0,1,0)*IF(COUNTIF(INDIRECT(F4),INDIRECT(F1))>0,1,0))

    Still an array formula.

  6. #6
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    Thanks for the reply. It will work. But is there a way that we can simplify the formula above?

    Assume that there are 100 names in cell F1, F2, ... F100, it will be difficult to use the individual form above. Is it possible to combine them as, for example, F1:F100?

    Sorry for the question.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Count the number of shared names by other groups

    If each name will only appear in each list a maximum of one time you could do it like this:
    =SUM(IF(COUNTIF(A2:D8,A2:A8)=4,1,0))
    but I don't know how to do that with the named range as indirect

    I could give you a vba solution but I'll see if anyone has an idea how to do it with formulas.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the number of shared names by other groups

    Hi,

    Just to clarify, can you give your expected results for the attached?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    My question is: the formula provided by ragulduy will work. But I don't want to repeat so many times for each of the components when there are say 100 groups (or named ranges). I hope to have some formula like ={SUM(IF(INDIRECT(F1)="","",IF(COUNTIF(INDIRECT(F2:F100),INDIRECT(F1))=0,0,1)))}, where cells of F1, ... F100 contain all the named ranges. Maybe this is difficult and impossible?

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the number of shared names by other groups

    I notice that each name appears precisely once in each Group - is this always the case?

    Regards

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    Hi XOR LX, thanks for your reply. That is correct. Cells F1, F2 specify the named ranges to be used.

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the number of shared names by other groups

    Then as ragulduy stated in post #7, it's simply necessary to check against any one of the Named Ranges, e.g. based on your attachment:

    =SUMPRODUCT(0+(COUNTIF(A2:D8,INDIRECT(F1))=COUNTA(F1:F4)))

    Regards

  13. #13
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Count the number of shared names by other groups

    @xor

    The problem I had was how to define the ranges using indirect.

    So f1-f4 contains the names of the ranges a1-a4,b1-b4,c1-c4 etc ... How do you apply the countif to range a1-d4 by building it from the individual names in column f?

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the number of shared names by other groups

    Oh, is that what is required?!

    Why on earth would you want/need to do that? Why not just have an extra Named Range for the entire range?

    Regards

  15. #15
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    Thanks for trying to help me out. If it is really impossible, then I just close the post to save your time. Much appreciated.

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the number of shared names by other groups

    No need to close, I'm sure. But can you just clarify that that is your wish, i.e. that the entire range should only ever be referenced via combining the Named Ranges, and not on itself?

    And what results did the formula I posted give?

    Regards

  17. #17
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    Hi XOR LX,

    For my particular problem, named ranges must be used. So I made an example and attached to show what I want to achieve. Say, there are 4 columns of data A, B, C and D. We name them as 4 groups respectively using the named ranges as: Group_1, Group_2, Group_3 and Group_4. Now we type these named ranges in cells F1, F2, F3 and F4 respectively. Then the formula provided by ragulduy can be used to check how many cases of Group_1 also exist in the other groups (that is, to check how many cases are not unique to Group_1):

    =SUM(IF(COUNTIF(INDIRECT(F2),INDIRECT(F1))>0,1,0)*IF(COUNTIF(INDIRECT(F3),INDIRECT(F1))>0,1,0)*IF(COUNTIF(INDIRECT(F4),INDIRECT(F1))>0,1,0))

    While this formula does work, the trouble is: if I have 100 named ranges like that for 100 groups, then I need to repeat tying the same formula for 100 times which is not ideal. That is why I hope to have a nice formula which combines them like F1:F100 to make life easy

  18. #18
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the number of shared names by other groups

    But this is what I don't understand.

    I'm not saying you can't use Named Ranges. Quite the opposite: I'm simply saying why you can't use one more! Namely, the range which encompasses all those other Named Ranges (assuming they are in contiguous columns, which they are in your example).

    That way the solution is a quite-straightforward modification to that I posted earlier.

    If you can't allow one more Named Range, then I have to say I'm puzzled to say the least!

    Regards

  19. #19
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Count the number of shared names by other groups

    Last edited by icestationzbra; 04-28-2014 at 04:25 PM.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  20. #20
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    Finally the formula provided by icestationzbra does work. I may need to spend dozens of hours to digest this formula, looks very advanced

    Thanks for help, everyone.

  21. #21
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: Count the number of shared names by other groups

    Points taken, XOR LX. I'm still learning but glad to learn

+ 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. [SOLVED] Count number of times names appear in a column
    By jeremysayshi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-06-2014, 01:24 PM
  2. [SOLVED] Count unique names only, not the number of times it appears
    By amyp22x3 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-04-2013, 01:32 PM
  3. [SOLVED] How to identify those names shared by two groups and do a sum-up?
    By zjianguk in forum Excel General
    Replies: 5
    Last Post: 03-14-2013, 12:53 PM
  4. Count Number of Unique Names in a List
    By acewriter63 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-09-2012, 09:12 AM
  5. [SOLVED] How to protect a shared sheet but allow groups to expand
    By Don Muller in forum Excel General
    Replies: 3
    Last Post: 09-29-2005, 09:05 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