+ Reply to Thread
Results 1 to 11 of 11

Sum multiple columns based on header

  1. #1
    Registered User
    Join Date
    06-15-2023
    Location
    United States
    MS-Off Ver
    2021
    Posts
    4

    Sum multiple columns based on header

    I have an excel file at which Im attempting to do a sum for all headers for a specific criteria.
    I was successful at creating a formula that allows to find multiple criteria's and sum a single header, however, Im struggling to
    create a formula that would allow me to sum multiple headers for that criteria without creating 20-30 sumifs and combine them.
    Much easier to have a list of headers like I did in the first example where users can change the criterias as needed. Trying to do the same for the headers.

    Any thoughts?

    More info explained:
    In my example, the Green 8 is correct because its summing the Header (H2) and summing all criteria's (a, b).
    Users have the ability to adjust the criteria (remove a, add c, etc..). Users have the ability to replace Header H2 to change it to H3 which will give you 12

    In the yellow highlights,
    I should get a count of 21 since your adding all criteria's (a) with headers (H2, H1, H4).
    Users should be able to modify the criteria and headerse.g., add c, remove a, Add H3) which in this example should then give them 20
    Attached Files Attached Files
    Last edited by MavMasterExcel; 06-15-2023 at 09:43 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Sum multiple columns based on header

    Welcome to the forum.

    Explain why 8 is correct for the green formula. Tell us what value you are expecting for the yellow formula (value, not description).
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    06-15-2023
    Location
    United States
    MS-Off Ver
    2021
    Posts
    4

    Re: Sum multiple columns based on header

    Thanks Ali, Ive updated my notes with an example

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Sum multiple columns based on header

    In my example, the Green 8 is correct because its summing finding the Header (H2) and summing all criteria's (a,b).
    But that's 4, not 8 ...

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    1
    H1
    H2
    H3
    H4
    group to sum Header to sum Formula
    2
    a
    1
    2
    3
    4
    a H2
    8
    3
    b
    1
    2
    3
    4
    b
    2+2=4
    Sheet: Sheet1
    I should get a count of 21 since your adding all criteria's (a) with headers (H2, H1, H4).
    I make that one 8. Don't understand - sorry.

  5. #5
    Registered User
    Join Date
    06-15-2023
    Location
    United States
    MS-Off Ver
    2021
    Posts
    4

    Re: Sum multiple columns based on header

    In your table, your missing rows 5 and 6 which also contain an the criteria: "a" and H2 has a value of 2 of each of those rows

    screenshot.JPG
    Last edited by MavMasterExcel; 06-15-2023 at 09:49 AM.

  6. #6
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,427

    Re: Sum multiple columns based on header

    Pls try

    Cell K2 formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Cell S2 formulas

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-15-2023
    Location
    United States
    MS-Off Ver
    2021
    Posts
    4

    Re: Sum multiple columns based on header

    Wow! Thanks, I do like that this is a lot cleaner and would love to use this for future examples .
    After testing the S2 formula I ran into two errors:
    -Users should be able to add more criteria's since its not always going to be one criteria. e.g., they should be able to b, c, d, etc...

    -The header group seems to be locked and has to be filled. in other words, less advanced users wont understand that the data in Column R cannot be blank.
    Im trying to do it where if I put Range R1:R5, it would sum all values in that range whether I have 5 values in there or only 1.
    Last edited by MavMasterExcel; 06-15-2023 at 10:10 AM.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Sum multiple columns based on header

    Quote Originally Posted by MavMasterExcel View Post
    In your table, your missing rows 5 and 6 which also contain an the criteria: "a" and H2 has a value of 2 of each of those rows

    Attachment 833208
    Doh!!!

    I'll go back to the gardening ...

  9. #9
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,005

    Re: Sum multiple columns based on header

    K2
    Please Login or Register  to view this content.
    s2
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,783

    Re: Sum multiple columns based on header

    K2=SUMPRODUCT((ISNUMBER(MATCH(A2:A100,I2:I100,0)))*(ISNUMBER(MATCH(B1:E1,J2:J100,0)))*(B2:E100))

    Add or remove group to sum or Header to sum in any order
    in the respective columns
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,783

    Re: Sum multiple columns based on header

    K2=SUMPRODUCT((ISNUMBER(MATCH(A2:A100,I2:I100,0)))*(ISNUMBER(MATCH(B1:E1,J2:J100,0)))*(N(+B2:E100)))

    For columns with number and text

+ 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] Delete Multiple Columns based on Header Name
    By kingsdime29x in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2019, 04:07 AM
  2. How to move multiple columns based on header name Help Needed!
    By AkAk0 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2016, 01:43 PM
  3. Sum multiple columns based on month header
    By pphg in forum Excel General
    Replies: 3
    Last Post: 04-21-2016, 03:52 AM
  4. Sum multiple columns based on header
    By towndrunk in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-14-2013, 10:00 AM
  5. [SOLVED] Sort multiple columns based on column header
    By Langer101 in forum Excel Programming / VBA / Macros
    Replies: 39
    Last Post: 01-09-2013, 09:55 AM
  6. Replies: 2
    Last Post: 10-13-2012, 03:30 AM
  7. Replies: 0
    Last Post: 05-12-2011, 04:24 PM

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