+ Reply to Thread
Results 1 to 8 of 8

Adding up cells across worksheets

  1. #1
    Registered User
    Join Date
    02-17-2015
    Location
    Hull
    MS-Off Ver
    2010
    Posts
    7

    Question Adding up cells across worksheets

    Hello,

    I am currently working on a calendar using excel to work out leave for staff. I have 12 tabs along the bottom for each month (named January to December) with a summery at the beginning. I have a formula for adding up the leave for all of the months: '=SUM(January:December!AG5)' however what I really want is for this calculation to end on the same month as the employee's start date (i.e. to account for the fact employee's leave is reset at different times of the year). I have made a formula for converting the start date into a month, and basically I'm asking is there a way to use this as a reference in the =SUM(January:December!AG5) to change the December into the correct month (i.e. I want to change December! into [cell reference]!)

    Thank you for any help you can give!

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Adding up cells across worksheets

    Try

    =SUM(INDIRECT("January:"&[cell reference]&"!AG5"))
    e.g.
    =SUM(INDIRECT("January:"&A1&"!AG5"))
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    02-17-2015
    Location
    Hull
    MS-Off Ver
    2010
    Posts
    7

    Re: Adding up cells across worksheets

    Nah doesn't seem to work, just comes back with #ref

  4. #4
    Registered User
    Join Date
    02-17-2015
    Location
    Hull
    MS-Off Ver
    2010
    Posts
    7

    Re: Adding up cells across worksheets

    Don't understand why either, when I do the evaluate thing it seems to work right up until the last step where it errors for no obvious reason :S

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

    Re: Adding up cells across worksheets

    You can't do 3d ranges with Indirect.

    I would recommend creating a helper column/row that pulls in all 12 cells information.
    Say
    A1 =January!AG5
    A2 =February!AG5
    A3 =March!AG5
    etc...

    Then put a month number in B1 to represent the employees Start Month (1 for Jan, 2 for Feb etc..)
    Then do
    =SUM(A1:INDEX(A1:A12,B1))

    Or if you'd prefer to just type the month name into B1
    =SUM(A1:INDEX(A1:A12,MONTH(B1&1)))
    Last edited by Jonmo1; 02-17-2015 at 11:54 AM.

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Adding up cells across worksheets

    Yes - surprisingly not so straightforward.

    An alternative set-up (though less efficient than Jonmo's) would be to first go to Name Manager and define SheetList as:

    ={"January","February","March","April","May","June","July","August","September","October","November","December"}

    (Or whatever happen to be the sheet names in question.)

    The required array formula** is then:

    =SUM(INDIRECT("'"&INDEX(SheetList,N(IF(1,ROW(INDEX(A:A,1):INDEX(A:A,MATCH([cell reference],SheetList,0))))))&"'!AG5"))

    where [cell reference] contains the desired end sheet name.

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Registered User
    Join Date
    02-17-2015
    Location
    Hull
    MS-Off Ver
    2010
    Posts
    7

    Re: Adding up cells across worksheets

    Thanks so much for the help guys! Ended up using Jommo1's idea, just opened up a separate calculations sheet which I'll hide at the end, thanks again

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

    Re: Adding up cells across worksheets

    You're welcome.

+ 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. Adding two cells in different worksheets using VBA
    By blaqrose in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2013, 04:35 AM
  2. Adding pairs of cells from different worksheets
    By walrasianxl in forum Excel General
    Replies: 3
    Last Post: 09-13-2010, 11:51 AM
  3. [SOLVED] Adding Cells across Worksheets
    By TJ7933 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-13-2006, 12:15 PM
  4. Adding cells from multiple Worksheets
    By Joe in forum Excel General
    Replies: 1
    Last Post: 10-06-2005, 02:05 PM
  5. [SOLVED] adding cells in multiple worksheets
    By Hrider in forum Excel General
    Replies: 2
    Last Post: 06-30-2005, 07:05 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