+ Reply to Thread
Results 1 to 7 of 7

Summing columns based on matched values

  1. #1
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Summing columns based on matched values

    Folks,

    I want to sum columns (C,E,G) for each row if the lookup value (for columns B,D,F) matches a separate list without adding separate IF conditions for each column.

    I need formulas (arrayed INDEX/MATCH perhaps..) for Column I and J of the attached.
    Attached Files Attached Files
    Last edited by Ace_XL; 10-11-2012 at 02:51 PM.
    Life's a spreadsheet, Excel!
    Say thanks, Click *

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

    Re: Summing columns based on matched values

    Try:

    =SUM(IF(ISTEXT(LOOKUP($B2:$F2,$K$1:$L$13)),IF(LOOKUP($B2:$F2,$K$1:$L$13)=I$1,$C2:$G2)))

    CSE confirmed and copied down and over
    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
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing columns based on matched values

    or better:

    =SUMPRODUCT(--(LOOKUP($B2:$F2&"",$K$1:$L$13&"")=I$1),$C2:$G2)

    Regular entered.

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Summing columns based on matched values

    Both formulas work great..!

    just one thing that baffled me ...why is the lookup range $K$1:$L$13 and not $K$2:$L$13?

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

    Re: Summing columns based on matched values

    Because the formulas are also trying to lookup the numbers, and if we go from L2, they would get back #N/A! errors, so we add the empty cells above, so the numbers return the null from L1 since numbers are less than text in the sense of LOOKUP function, so last value smaller than or equal to the number is the blank cell at the top. That, and adding the nulls to the range references in the Sumproduct formula helps eliminate any #N/A errors, making the data "clean" for Sumproduct to work...

  6. #6
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Summing columns based on matched values

    Cheers NBVC..that rounds off another great day of learning!

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

    Re: Summing columns based on matched values

    another option:

    Please Login or Register  to view this content.
    - 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 -

+ 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