+ Reply to Thread
Results 1 to 6 of 6

Sum a range of cells in multiple worksheets that meet two criteria

  1. #1
    Registered User
    Join Date
    07-11-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2011
    Posts
    25

    Question Sum a range of cells in multiple worksheets that meet two criteria

    Hi forum,

    I log time spent on different tasks across multiple projects (tasks listed in columns, projects listed in rows).
    Each new year, I create a new worksheet that tracks the same information.
    As projects start and finish, they appear and disappear in the yearly worksheets.

    I'm trying to create a formula on a summary page that adds all hours spent on a given project and a given task.

    The formula I'm trying to use is:
    =SUMPRODUCT(SUMIFS(INDIRECT("'"&B69:B78&"'!Q:BD"),INDIRECT("'"&B69:B78&"'!Q7:BD7"),B8,INDIRECT("'"&B69:B78&"'!C:C"),A9))

    Where:
    B69:B78 is a list of the worksheet names
    Q:BD are the columns that have the hours logged in them
    Q7:BD7 are the task names
    B8 is the task to check against
    C:C is the column that has the project names in it
    A9 is the project to check against

    However, it returns the #VALUE error.

    Any help would be much appreciated!

    Thanks,
    U

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

    Re: Sum a range of cells in multiple worksheets that meet two criteria

    Let's forget about the multiple sheets for now (for troubleshooting purposes), and just look at the basic formula without the indirect.
    You have
    =SUMPRODUCT(SUMIFS(SomeSheet!Q:BD,SomeSheet!Q7:BD7,B8,SomeSheet!C:C,A9))

    That syntax isn't going to work.
    Sumifs requires the SumRange and CriteriaRanges to be of equal dimensions.

    It looks like you're trying to find the column to sum based on finding B8 in SomeSheet!Q7:BD7
    Try that like this

    =SUMPRODUCT(SUMIFS(INDEX(SomeSheet!Q:BD,0,MATCH(B8,SomeSheet!Q7:BD7,0)),SomeSheet!C:C,A9))

    Make sure that works correctly for 1 specific sheet.
    Then put the indirect back in.

  3. #3
    Registered User
    Join Date
    07-11-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2011
    Posts
    25

    Re: Sum a range of cells in multiple worksheets that meet two criteria

    Thanks Jonmo1.

    Are you intending for your function to be entered as an array (i.e. for the INDEX function to return an array of values?). Since the intention is to sum a whole bunch of specific cell references, I assume the answer is yes?

    EDIT: Actually, I'm not sure the above makes sense. I guess my question is really about whether your function will return multiple values i.e. looking down one column, I want to add every value based on finding B8.

    EDIT EDIT: Ha, I just got your function working (no INDIRECT yet), so far so good.
    Last edited by Uomoviso; 07-12-2016 at 03:28 AM.

  4. #4
    Registered User
    Join Date
    07-11-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2011
    Posts
    25

    Re: Sum a range of cells in multiple worksheets that meet two criteria

    Okay, I'm getting stuck when I try to enter the INDIRECT function.

    The basic function without INDIRECT gives me all the right values on worksheet 2017:

    =SUMPRODUCT(SUMIFS(INDEX('2017'!Q:BD,0,MATCH(H8,'2017'!Q7:BD7,0)),'2017'!C:C,A22))

    But when I try and generalise it to all worksheets, it returns the #VALUE error:

    =SUMPRODUCT(SUMIFS(INDEX(INDIRECT("'"&B69:B78&"'!Q:BD"),0,MATCH(H8,INDIRECT("'"&B69:B78&"'!Q7:BD7"),0)),INDIRECT("'"&B69:B78&"'!C:C"),A22))

    Where B69:B78 in the current sheet is a list of all worksheets.

    Any suggestions?

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

    Re: Sum a range of cells in multiple worksheets that meet two criteria

    Honestly, I don't know if you're going to be able to do that.
    You may have to have 1 cell for a separate sumifs for each sheet, then sum those.

  6. #6
    Registered User
    Join Date
    07-11-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2011
    Posts
    25

    Re: Sum a range of cells in multiple worksheets that meet two criteria

    Yeah, I'm finding myself getting bogged down a bit. I've tried a slightly different tack though:

    =SUMPRODUCT(SUMIF(INDIRECT("'SomeSheets'!$C:$C"),$A8,INDIRECT("'SomeSheets'!Q:Q")))

    This works fine as long as the sum range remains within the Q:Q column, however for some sheets it might be U:U or even AA:AA. What I need to work out is how to replace the Q:Q with a column that matches a certain criteria i.e. find the column on SomeSheets where the cell in row 1 matches the text string "XX".

    I've tried swapping the Q:Q out for your INDEX / MATCH function, but it breaks. I've also toyed with COLUMN, VLOOKUP etc., but no dice.

    Solvable?

+ 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] Macro to clear cells in range & move up if certain cells meet criteria
    By samder68 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-09-2016, 10:52 PM
  2. [SOLVED] COUNTIF on range of cells that meet 2 criteria
    By mattsafact in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-06-2016, 10:54 AM
  3. [SOLVED] Help with loop to select range of cells that meet criteria
    By NU2vba in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2016, 02:27 AM
  4. [SOLVED] Counting cells that meet multiple single criteria as variable criteria
    By BillBasil in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-01-2016, 10:33 AM
  5. Paste range of cells that meet criteria
    By lorena.tgarza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2012, 09:51 PM
  6. Replies: 15
    Last Post: 02-19-2011, 12:40 PM
  7. sum a range of cells that meet one criteria
    By shanevo6 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-10-2007, 04:06 PM

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