+ Reply to Thread
Results 1 to 9 of 9

Indirect Sumifs with Or Criteria

  1. #1
    Registered User
    Join Date
    04-27-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Post Indirect Sumifs with Or Criteria

    I'm trying to sum a range of cells across multiple sheets if they meet certain cell referenced criteria. There are some cases where it will be a single criteria and others where it will be either or.

    I can get single and multiple criteria to work with direct sheet reference but I'm trying to avoid having a long formula with several sumifs added together. I tried using indirect and I can get it to work with a single criteria but when I use two criteria the result is wrong. The criteria and sum ranges will be the same on all sheets.

    I've attached an example for reference. Oh and this has to be an xlsm file because it links to an database. Any help would be appreciated.
    Thanks,
    Attached Files Attached Files

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Indirect Sumifs with Or Criteria

    I didn't download your file.

    Show us the formula you tried that didn't work.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Indirect Sumifs with Or Criteria

    You can accomplish OR logic within a SUMIFS function, but the criteria has to be explicitly declared.

    =SUMPRODUCT(SUMIFS(INDIRECT("'"&Sheet&"'!E:E"),INDIRECT("'"&Sheet&"'!B:B"),{"SUB.2","SUB.3"}))

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Attached Images Attached Images
    Last edited by daffodil11; 07-27-2015 at 06:48 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Indirect Sumifs with Or Criteria

    Quote Originally Posted by daffodil11 View Post
    You can accomplish OR logic within a SUMIFS function, but the criteria has to be explicitly declared.

    =SUMPRODUCT(SUMIFS(INDIRECT("'"&Sheet&"'!E:E"),INDIRECT("'"&Sheet&"'!B:B"),{"SUB.2","SUB.3"}))
    You can put the criteria in a horizontal range of cells.

    =SUMPRODUCT(SUMIF(INDIRECT("'"&Sheets&"'!B:B"),B2:C2,INDIRECT("'"&Sheets&"'!E:E")))

  5. #5
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Indirect Sumifs with Or Criteria

    Woah, changing the workbook! That's against the rules!

  6. #6
    Registered User
    Join Date
    04-27-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Indirect Sumifs with Or Criteria

    Thank you for your help.

    Daffodill, the formula you gave me worked but I need the criteria to be cell reference because the file will become a template and need to be changed per project and there could be up to 20 assets. Also, I don't believe the formula was a true array as it worked without using CTR+SHIFT+ENTER.

    Tony, changing the criteria to a horizontal may be an option but it will require changing the layout of the spreadsheet. Can you explain why it works horizontal and not vertical? It will definitely be useful knowledge in the future.
    Thanks,
    Last edited by cloechl; 07-27-2015 at 08:36 PM.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Indirect Sumifs with Or Criteria

    Quote Originally Posted by cloechl View Post
    Tony, changing the criteria to a horizontal may be an option but it will require changing the layout of the spreadsheet. Can you explain why it works horizontal and not vertical? It will definitely be useful knowledge in the future.
    That's just how it works. A range of criteria has be in the opposite direction of the referenced range.

    If you don't want to rearrange the criteria cells then you can use this array entered** version:

    =SUM(SUMIFS(INDIRECT("'"&Sheet&"'!E:E"),INDIRECT("'"&Sheet&"'!B:B"),TRANSPOSE(B25:B26)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Also, since there is just a single criteria range you can simply use SUMIF although SUMIFS will still work.

  8. #8
    Registered User
    Join Date
    04-27-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Indirect Sumifs with Or Criteria

    I'm still a little confused.
    The formula =SUMPRODUCT(SUMIFS('01 Pre Eng'!E:E,'01 Pre Eng'!B:B,B20:B21)) has all vertical ranges and returns the correct value.

    But when I substitute Indirect for the specific sheet reference it returns the wrong value.
    =SUMPRODUCT(SUMIFS(INDIRECT("'"&Sheet&"'!E:E"),INDIRECT("'"&Sheet&"'!B:B"),B20:B21))

    The only difference I can see between the 2 is the nested Indirect formula. Does Indirect somehow effect the array?

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Indirect Sumifs with Or Criteria

    Yes, plus one formula is calculating across multiple sheets while the other formula is calculating from a single sheet.

+ 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. Sumifs for row and column and indirect in one
    By nilani in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-01-2015, 07:18 AM
  2. [SOLVED] Indirect and substitute formua with sumifs
    By EmilyB in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-17-2014, 08:56 PM
  3. [SOLVED] Non-volatile replacement for INDIRECT in SUMIFS formula
    By Lotrking1010 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-04-2013, 11:06 AM
  4. Replace SUMIFS with INDIRECT
    By MrPeterified in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-21-2013, 05:19 PM
  5. [SOLVED] Cannot get INDIRECT function to work with SUMIFS
    By kborgers in forum Excel General
    Replies: 6
    Last Post: 11-22-2012, 11:21 AM
  6. Using Indirect with Sumifs
    By JohnGault82 in forum Excel General
    Replies: 8
    Last Post: 02-08-2011, 04:05 AM
  7. Excel 2007 : Sumifs and Indirect
    By MoonWeazel in forum Excel General
    Replies: 2
    Last Post: 10-14-2010, 05:11 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