+ Reply to Thread
Results 1 to 4 of 4

count sorted values

  1. #1
    Registered User
    Join Date
    03-06-2017
    Location
    China
    MS-Off Ver
    Excel 2013
    Posts
    2

    count sorted values

    I would like to count (make a sum) like the example below, which is sorted to ID1. But because of the reference Excel uses, the sum is not stable when I re-sort the whole table to ID2. How can I solve this?

    ID1 ID2 NAME VALUE SUM FUNCTION
    1 12 GROUP ID1 2-4 0 16 sum(D3:D5)
    2 9 1
    3 5 5
    4 10 10
    5 7 GROUP ID1 6-8 0 75 sum(D7:D9)
    6 8 20
    7 11 25
    8 1 30
    9 3 GROUP ID1 10-12 0 135 sum(D11:D13)
    10 2 40
    11 4 45
    12 6 50


    ID1 ID2 NAME VALUE SUM FUNCTION
    8 1 30
    10 2 40
    9 3 GROUP ID1 10-12 0 100 sum(D11:D13)
    11 4 45
    3 5 5
    12 6 50
    5 7 GROUP ID1 6-8 0 31 sum(D7:D9)
    6 8 20
    2 9 1
    4 10 10
    7 11 25
    1 12 GROUP ID1 2-4 0 0 sum(D3:D5)

    (how do I paste an excel table?)

    sumif is not really an option since it takes way to long to program
    Attached Files Attached Files

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: count sorted values

    if there is a name in a row:
    =SUMPRODUCT($D$2:$D$13,--($A$2:$A$13>=--MID(C2,FIND($A$1,C2)+4,FIND("-",C2)-FIND($A$1,C2)-4)),--(A2:A13<=--MID(C2,FIND("-",C2)+1,10)))

  3. #3
    Registered User
    Join Date
    03-06-2017
    Location
    China
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: count sorted values

    Thanks for the answer, when I change your last array into $A$2:$A$13 it works!
    but isn't there an easier way? Because this example is a simplified version of wat I really need to do and that are +- 100 groups of 5 - 20 records. So this will take too much time to program.
    It feels so basic that there should be something like adding a $ to make it stick to the cell.

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,557

    Re: count sorted values

    Hello Bertenvanl and Welcome to Excel Forum.
    If you wrap Tim's formula in the IFERROR function you can paste it into E2 and double click the fill handle so that it will automatically copy down as far as needed.
    The formula will read:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. Replies: 6
    Last Post: 09-27-2015, 07:54 AM
  2. Replacing sorted values with 1,2,3 etc
    By motorcycle in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 03-14-2015, 05:33 PM
  3. Replies: 2
    Last Post: 03-07-2015, 08:17 PM
  4. Replies: 1
    Last Post: 03-06-2015, 09:54 PM
  5. Replies: 0
    Last Post: 03-06-2015, 03:07 PM
  6. Replies: 0
    Last Post: 03-06-2015, 12:43 PM
  7. how to count records in a sorted list
    By Ellen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-13-2005, 12:05 PM

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