+ Reply to Thread
Results 1 to 10 of 10

Multiple lookup criteria and sum values based on matches.

  1. #1
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Lightbulb Multiple lookup criteria and sum values based on matches.

    Hi There,

    Following is the scenario i ran into:

    I have input sheet with several combinations entered by user as shown below:

    A1 A2 A3

    A X S
    M F T
    C D F
    N C D
    Y A
    Z

    where A1, A2, and A3 are headers/range with values as header names of columns used in sheet 2.

    In sheet 2, i have around 100 rows with data entered (all numbers) for column headers A, B, C, D...Z. Now, i will ask user to enter the Combination (as defined in input sheet) after the last used column, after entering the required combination, i would like to add the values for that combination. By that i mean, say if user selected A1, then i would like to add the row values of columns A, M, C, N, Y, Z as defined in input sheet.

    I played around with using SumIFS and other array functions but couldnot get it to work.

    Any help would be greatly appreciated.

    Thanks in advance and please let me know if further clarification is required.

    Sat.
    Attached Files Attached Files
    Last edited by skonduru; 01-25-2016 at 06:07 PM. Reason: Descriptive Title

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: Need help with array formula

    Please post a sample file showing expected outcomes.

  3. #3
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Need help with array formula

    Hi John,

    Please find the attached sample file attached to my original post.

    Thanks,

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Multiple lookup criteria and sum values based on matches.

    Try this...
    =SUMPRODUCT(C$2:AB$2,--($C$1:$AB$1=Sheet1!A2)+($C$1:$AB$1=Sheet1!A3)+($C$1:$AB$1=Sheet1!A4)+($C$1:$AB$1=Sheet1!A5)+($C$1:$AB$1=Sheet1!A6)+($C$1:$AB$1=Sheet1!A7))
    copied down and across

    edit: JeteMc just pointed out some incorrect absoluting in my formula - thanks for that. It should have been...
    =SUMPRODUCT($C2:$AB2,--($C$1:$AB$1=Sheet1!A$2)+($C$1:$AB$1=Sheet1!A$3)+($C$1:$AB$1=Sheet1!A$4)+($C$1:$AB$1=Sheet1!A$5)+($C$1:$AB$1=Sheet1!A$6)+($C$1:$AB$1=Sheet1!A$7))
    Last edited by FDibbins; 01-25-2016 at 06:18 PM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Multiple lookup criteria and sum values based on matches.

    Try this on Sheet2 in AD2 and filled right/down

    =SUMPRODUCT(SUMIF($C$1:$AB$1,Sheet1!A$2:A$10,$C2:$AB2))

  6. #6
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Multiple lookup criteria and sum values based on matches.

    Thanks FDibbins,

    Is there a way of making it dynamic? by defining dynamic ranges for A1, A2 so on in input sheet and searching for column names in those ranges?

    Kon

  7. #7
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Multiple lookup criteria and sum values based on matches.

    Thanks Jonmo1. It worked like a charm.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Multiple lookup criteria and sum values based on matches.

    Nice 1 Jonmo

    This ARRAY formula also works...
    =SUM(SUMIF($C$1:$AB$1,Sheet1!A$2:A$7,$C2:$AB2))
    entered using CTRL SHFT ENTER

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Multiple lookup criteria and sum values based on matches.

    Dynamically searching for AD1 in Sheet1 A1:C1

    =SUMPRODUCT(SUMIF($C$1:$AB$1,INDEX(Sheet1!$A$2:$C$10,0,MATCH(AD$1,Sheet1!$A$1:$C$1,0)),$C2:$AB2))

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Multiple lookup criteria and sum values based on matches.

    Thanks for the feedback

+ 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. Question about using Evaluate with an array of formulas not an array formula
    By Mr_Bill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2014, 03:26 PM
  2. Can I make the row lookup array/range part in an array formula variable?
    By OLLY-7 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-18-2014, 09:06 AM
  3. Array formula + Array formula with criteria that lookups a Table
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-16-2013, 11:41 AM
  4. Replies: 6
    Last Post: 05-26-2012, 04:56 AM
  5. Replace hard coded array in formula with link to input array
    By David Brown in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-08-2011, 07:45 AM
  6. Converting 3x10 array to a 1X30 array to run a Match formula
    By NBVC in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-08-2009, 07:45 AM
  7. [SOLVED] Tricky array formula issue - Using array formula on one cell, then autofilling down a range
    By aspenbordr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2005, 11:05 AM

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