+ Reply to Thread
Results 1 to 12 of 12

Sum Salaries from separate sheets - Sheet names in a dynamic array

  1. #1
    Registered User
    Join Date
    10-06-2011
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    78

    Sum Salaries from separate sheets - Sheet names in a dynamic array

    Hello,

    I'm trying to sum data on different sheets in a workbook. I want the specific list of sheets to sum to be dynamic and controlled by a "Control" sheet where I can turn "on" and "off" each sheet. I'd like to create an array of sheet names in a named range, and then sum the data from the sheets in the named range using a combination of INDIRECT, SUM, and SUMPRODUCT functions. I can't seem to get the named range to work.

    I'm open to other methods as well.

    It's a little complicated so I am attaching a file. Let me know if you have questions.
    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: Sum Salaries from separate sheets - Sheet names in a dynamic array

    Try this array formula**:

    =SUM(IF(B4:D4="On",SUMIF(INDIRECT("'"&B3:D3&"'!B2"),">0")))

    ** 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.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    10-06-2011
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    Thanks Tony. Your solution definitely works, but in practice I think I need it to have the array formula set as a Named range. By placing the array formula in the Named range, I won't have to have array formulas in the spreadsheets.

    Can you help me find a solution that uses an array formula in a Named range? I attached an updated file to summarize.
    Attached Files Attached Files

  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: Sum Salaries from separate sheets - Sheet names in a dynamic array

    <-- this works, but I can't use array formulas in the spreadsheet
    You can't use array formulas or you don't want to use array formulas?

    Without the use of intermediate calculations I don't think it can be done without an array formula.

    Don't be afraid of array formulas!

  5. #5
    Registered User
    Join Date
    10-06-2011
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    Oh yes, I do want an array formula, I just want it within the name manager.

    One partial solution I gave in the updated file uses an array formula in the name manager (Employee_Offset_array). It works great to sum all off the sheets in the range, but it doesn't exclude sheets when On/Off is set to "Off". I was hoping there is a way to combine your solution with the "Employee_Offset_array" solution so that there is an array formula in name manager, the On/Off works, and the worksheet formula is not an array formula. Do you think that's possible?

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

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    I'll be going offline for several hours.

    I'll get back to ya!

  7. #7
    Registered User
    Join Date
    10-06-2011
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    Thanks Tony!

    In the meantime if anyone can find a solution, that would be great too.

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

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    Here's what I came up with but it requires an intermediate calculation.

    You need to compile a list of the sheet names to be included in the calculation and this list needs to be such that all the sheets that meet the condition have to be in a contiguous range.

    For example...

    Data Range
    A
    B
    C
    D
    3
    Name:
    James
    Mary
    Laura
    4
    On/Off:
    On
    Off
    On
    5
    6
    7
    8
    9
    10
    James
    11
    Laura
    12
    #NUM!
    13
    #NUM!
    14
    #NUM!
    15
    #NUM!


    This array formula** entered in A10 and copied down to A15:

    =INDEX($3:$3,SMALL(IF(B$4:D$4="On",COLUMN(B4:D4)),ROWS(A$10:A10)))

    ** 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.

    Then, to get the sum across the sheets:

    =IFERROR(SUMPRODUCT(SUMIF(INDIRECT("'"&A10:INDEX(A10:A15,MATCH("zzzzz",A10:A15))&"'!B2"),"<>0")),0)

  9. #9
    Registered User
    Join Date
    10-06-2011
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    That's good. It works. I just wish there was a way to not have the middle step. Why do the values have to be in a contiguous range? Any idea?

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

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    We have to pass only the sheet names to the INDIRECT function to form a valid reference otherwise INDIRECT would generate an error.

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

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    I don't see any advantage in using the array formula to generate the sheet names over using the array formula to get the sum.

    Seems like an extra unnecessary step.

  12. #12
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Sum Salaries from separate sheets - Sheet names in a dynamic array

    How about this...

    =SUMPRODUCT((B4:D4="On")*SUMIF(INDIRECT("'"&B3:D3&"'!B2"),"<>0"))

+ 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] Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?
    By graym463 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-24-2015, 10:15 AM
  2. [SOLVED] Create an Array which has Sheet Names excluding a Few Sheet Names to be used in a MACRO
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-29-2013, 03:24 PM
  3. Replies: 1
    Last Post: 08-23-2013, 09:01 AM
  4. Dynamic array, info one sheet to another based on criteria then macro to print sheets
    By jmendenhall22 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2013, 10:25 AM
  5. Sum across sheets with dynamic names
    By TrickY101 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-04-2013, 04:54 AM
  6. Create array of file names/sheet names
    By BVHis in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-06-2008, 11:30 AM
  7. adding salaries with the same names
    By si_ako in forum Excel General
    Replies: 4
    Last Post: 03-14-2007, 06:22 AM

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