Results 1 to 6 of 6

Thread: Sum All Rows And Columns In A Range Where Criteria Matches Across Rows And Columns

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0

    Sum All Rows And Columns In A Range Where Criteria Matches Across Rows And Columns

    Thank you in advance for any help you might lend in answering this question.

    I believe I have this formula entered correctly, but I am getting an error value. Any tips on how I might improve it? I am sure I've used Sumifs in similar situations before with good results.

    SumifSError.jpg

  2. #2
    Junior Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0
    Sorry, this example only contains two condition ranges, one for row labels and one for column headers (vertical and horizontal).

  3. #3
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    normonster, if the States and Brands do not repeat itself, then you can use this formula (in K2, based on the snapshot)

    =INDEX($B$2:$D$5,MATCH(I2,$A$2:$A$5,),MATCH(J2,$B$ 1:$D$1,))

    However, if the States and/or Brands are not unique, ie, if there are possibly the same State repeating itself as you go down the row, or Brands repeat itself across the columns, then you can use an array formula (again, in K2, according to the picture you posted)

    =SUM(IFERROR(N(INDIRECT(IF($A$2:$A$12=I2,"R"&ROW($ A$2:$A$12),0)&IF($B$1:$F$1=J2,"C"&COLUMN($B$1:$F$1 ),0),FALSE)),0))

    For a sample, please find attached a workbook using both the solutions
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  4. #4
    Junior Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0
    Thank you very much Fox. Your response is very much appreciated.

    I don't mean to resist your solution, but the SumifS function seems far more simple. Are you just partial to the INDEX function or do you believe that the SumifS function will not work with multiple conditions when they are spread over both Rows and Columns? I swear I have used the SumifS function in instances just like this before, but I could be wrong. Can you offer me any clarification in terms of the suitability of the SumifS function in this circumstance?

    Again, thank you so much.

  5. #5
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Sumifs using multiple criterias with criteria ranges spread across - Microsoft Community

    which translate to =SUMIFS(INDEX($B$2:$D$5,,MATCH(J2,$B$1:$D$1,)),$A$ 2:$A$5,I2) in your case

    Is this what you are looking for? Great if yes.

    The problem there is that the duplicates are only in the column, and not across the row also. If there are duplicates across the column and row, as in my example above, then I (seriously) doubt SUMIFS alone can handle it.

    Another way this can be done is using SUMPRODUCT. The advantage here is that it works equally well when there are duplicate column and row headers as when there are unique.

    =SUMPRODUCT(($A$2:$A$12=I2)*($B$1:$F$1=J2),$B$2:$F $12)
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  6. #6
    Junior Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0
    Thank you Sir. I guess Sumproduct is the way to go and it is indeed a great function. I appreciate your help.

Similar Threads

  1. Replies: 8
    Last Post: 04-20-2014, 10:15 PM
  2. seprate data in rows to columns
    By CORAL in forum Excel Help
    Replies: 2
    Last Post: 03-10-2014, 08:18 AM
  3. Replies: 6
    Last Post: 08-14-2013, 04:25 PM
  4. Move data from rows into columns for every unique value
    By mahmoud-lee in forum Excel Help
    Replies: 4
    Last Post: 06-13-2013, 03:02 AM
  5. Hide and Unhide Rows and Columns
    By Admin in forum Download Center
    Replies: 0
    Last Post: 05-11-2011, 12:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •