+ Reply to Thread
Results 1 to 22 of 22

sumifs over varing sheets

  1. #1
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    sumifs over varing sheets

    Dear heros,

    I'm trying to sum over several sheets. The numbers are only summed if they are in a certain category. The sheet number and the names are variable.
    The sheet names are written in F1:F7. However, it might be the case that e.g. F6 and F7 are empty. The number to be summed is written in A2, its category in A1. I only sum if the category is the same as the one in C2.

    I have:
    Please Login or Register  to view this content.
    Now when F6 and F7 are empty I get #REF. What can I do to ignore the empty cells?

    Thank you heros for saving me,
    hänschendampf

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: sumifs over varing sheets

    Not having attachment to test more advanced concepts, I'd propose a conservative one:

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

    Kaper

  3. #3
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    Hi Kaper,

    Thanks for the fast reply. It works very well for the little example. However the final application will have around 80 sheets. Do you think there is a faster way to do it?

    I attached the example.

    Cheers
    hänschendampf
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    pgc01 from mrexcel forum got the answer:

    Filter the empty cells, like:

    =SUM(IF(F1:F7<>"";SUMIF())

    This is an array formula, you have to confirm it with CTRL-SHIFT-ENTER and not just ENTER.

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

    Re: sumifs over varing sheets

    Try this array formula**:

    =SUM(IF(ISNUMBER(SUMIF(INDIRECT("'"&F1:F7&"'!A1"),C2,INDIRECT("'"&F1:F7&"'!A2"))),SUMIF(INDIRECT("'"&F1:F7&"'!A1"),C2,INDIRECT("'"&F1:F7&"'!A2"))))

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

    Replace the commas with semi-colons.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    Jup, this works as well. Thanks Tony

    Can you suggest a tutorial for array formulas? I encountered them several times but never managed to entirely understand it.

  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: sumifs over varing sheets

    Filter the empty cells, like:

    =SUM(IF(F1:F7<>"";SUMIF())
    Yes, that's better!

  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: sumifs over varing sheets

    Quote Originally Posted by hänschendampf View Post
    Can you suggest a tutorial for array formulas?
    See this...

    http://www.cpearson.com/Excel/ArrayFormulas.aspx

  9. #9
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    Thanks a lot :-)

  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: sumifs over varing sheets

    You're welcome!

  11. #11
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    mmmh, I have a new problem. I want to have the categories of the sheets in G1:G7 (the row next to the sheet names)

    So I take the code:
    Please Login or Register  to view this content.
    But now the sum over all sheets is calculated if G1 is the same as A5, no matter what's in G2:G7.

    Any idea?

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

    Re: sumifs over varing sheets

    Sorry, I don't understand.

  13. #13
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    First I had this:
    Please Login or Register  to view this content.
    Here I checked the "category" which was written for each sheet in A1 is corresponding to $A$5 in the first sheet.

    Now I don't want to have the "categories" in each sheet at A1 but rather in the range G1:G7 in the first sheet.
    Please Login or Register  to view this content.
    This however seems not to work. It gives me fancy numbers.

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

    Re: sumifs over varing sheets

    Quote Originally Posted by hänschendampf View Post
    ={SUM(IF($F$1:$F$7<>"";SUMIF($G$1:$G$7;$A$5;INDIRECT("'"&$F$1:$F$7&"'!"&"R"&ROW(A2)&"C"&COLUMN(A1);FALSE))))}
    Still not sure I understand.

    Can you post a SMALL sample file and show us what result you expect?

  15. #15
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    @Tony Valko

    I very much appreciate your help. But I just realized that this way is leading nowhere. I will have to rearrange my dataset.

    Thanks Tony.

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

    Re: sumifs over varing sheets

    OK, thanks for the feedback!

  17. #17
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    Hi everybody

    I have a little attachment, which hopefully helps to understand my problem:

    In E1:E10 the tables that I want to include are listed. In A1 I sum all the A1's from the tables that are listed in E1:E10. Later I want to sum all the A2's in A2, B1's in B1 and so on.

    As you see for summing A1 it all works well. The problem is, when I add a number in any sheet in column A below A1 (e.g. first!A2 = 2) it gets added up which is not my intention. It would be so helpful if someone could dig in my formula to find the error.
    Attached Files Attached Files

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

    Re: sumifs over varing sheets

    Quote Originally Posted by hänschendampf View Post
    As you see for summing A1 it all works well.
    I downloaded your file and the formula is returning a #REF! error.

    I don't understand what you want to do. Do you want to sum cell A1 on the sheets listed in column E?

  19. #19
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    really? is it possible that there is a mistake in translation? I'm using the german version...
    here's the german code:
    Please Login or Register  to view this content.
    In cell A1 of MAIN I want to sum all the cells A1 from the sheets in column E.

    So e.g.:
    MAIN!A1 = first!A1 + second!A1 + third!A1 + fourthA1
    In the attached example the result should be 10.

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

    Re: sumifs over varing sheets

    Here's the formula entered in cell A1 on the Main sheet:

    =SUM(IF(E1:E10<>"",SUMIF(E1:E10,"<>"&"",INDIRECT("'"&E1:E10&"'!"&"z"&ROW(first!A1)&"s"&COLUMN(first!A1),FALSE)),0))

    It returns a #REF! error.

    To sum cell A1 on the sheets listed in column E...

    Array entered**:

    =SUM(IF(E1:E10<>"",SUMIF(INDIRECT(E1:E10&"!A1"),"<>")))

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

  21. #21
    Registered User
    Join Date
    03-24-2016
    Location
    Bern, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    15

    Re: sumifs over varing sheets

    Hi Tony, thanks for your post. This works just great!

    So I think in English you would have to change "z" into "r" and "s" into "c". In the indirect function I chose the R1C1 style since I want to drag the formula to other cells later. It works well. I don't even try to translate ;-):
    Please Login or Register  to view this content.

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

    Re: sumifs over varing sheets

    Good deal. Thanks for the feedback!

+ 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] sum numbers over several sheets with varing starting / ending point
    By hänschendampf in forum Excel General
    Replies: 13
    Last Post: 03-30-2016, 11:26 AM
  2. [SOLVED] SUMIFS across multiple sheets
    By keith740 in forum Excel General
    Replies: 12
    Last Post: 06-08-2015, 04:51 PM
  3. SUMIFS across 2 sheets
    By soph239 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-12-2015, 11:43 AM
  4. [Question] Sumifs multiple sheets with flexible sheets reference
    By tranhaithang in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-29-2014, 04:53 AM
  5. Extract text between two characters in a string - varing text length
    By luv2birdie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-04-2014, 06:10 PM
  6. Need to modify macro, to deal with varing # of columns
    By TallOne in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-12-2012, 02:17 PM
  7. Sumifs across sheets
    By bestephens in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-25-2011, 01:58 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