+ Reply to Thread
Results 1 to 7 of 7

function for sorting/counting

  1. #1
    Registered User
    Join Date
    04-29-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    4

    Question function for sorting/counting

    Hi all,

    I have a two column worksheet, ColumnA is a list of names and ColumnB is a list of numbers.

    Example: (formatting in HTML is a little screwy but...)

    A B
    Derrek 10
    Frank 8
    Jane 20
    Derrek 50
    Sue 30
    Sue 30
    Tom 20
    Emily 15
    Derrek 14

    The list is extremely long, and has multiples of the same name. I would like to get a total for ColumnB, but only count the highest number when there are duplicates.

    So in this example, the total should end up being: 143.

    The problem I am encountering is that when I remove duplicates, it is only removing Sue's 30 since both ColumnA and ColumnB are the same. It does not remove Derrek's 14 or Derrek's 10 since ColumnB is not a duplicate number.

    Is there a function or even a multi-step process I can use to solve this issue?

    Thanks in advance!

    Drew
    Last edited by awelliott; 05-04-2010 at 01:00 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Is there a function for this type of sorting/counting?

    Perhaps in 2 steps:

    If data is A1:B9, then:

    =IF(SUMPRODUCT(--(A$1:A1=A1),--(B$1:B1=B1))>1,"",IF(B1=MAX(IF($A$1:$A$9=A1,$B$1:$B$9)),B1,""))

    adjust ranges to suit and then confirmed with CTRL+SHIFT+ENTER
    and copied down...

    Then sum that column.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Valued Forum Contributor
    Join Date
    02-08-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: function for sorting/counting

    One more option, data in range A1:B9.

    Formula in C1 copy down to C9
    =IF(COUNTIF($A$1:A1,A1)=1,MAX(INDEX(($A$1:$A$9=A1)*$B$1:$B$9,0)),0)

    Total
    =SUM(C1:C9)

    Regards
    Last edited by sailepaty; 04-29-2010 at 08:34 PM. Reason: To use a less expensive formula

  4. #4
    Registered User
    Join Date
    04-29-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    4

    Thumbs up Re: function for sorting/counting

    Great!

    I'm going to try these two out this weekend and get back to you.

    Thank you both for your help!

    Drew

  5. #5
    Registered User
    Join Date
    04-29-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: function for sorting/counting

    Hi Guys,

    I was able to get the second formula to work well. The only thing to note is that sometimes the first cell in ColumnB is counted when it is not the largest number. So its important to check that when reviewing your results. Everything else worked perfectly.

    Thanks again!!

    Drew

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: function for sorting/counting

    Are you sure that all the names that matched that first cell had no extra spaces or something that makes them not exact matches?

  7. #7
    Registered User
    Join Date
    04-29-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: function for sorting/counting

    You're right! There was a space. Thanks again.

    Drew

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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