+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : Argument substitution in SUM

  1. #1
    Registered User
    Join Date
    12-23-2010
    Location
    Nova Scotia, Canada
    MS-Off Ver
    Excel 2003
    Posts
    1

    Argument substitution in SUM

    Good Afternoon Everyone,

    First Happy Holidays !
    I am having a problem substituting an argument within the SUM function.
    I have a basic spreadsheet which I use to account for my time throughout the year. The WorkBook starts as a single template which is copied to each Week (sheet) as it is needed culminating in 50+ sheets by years end.
    One function that is handy is to be able to look at the cumulative hrs spent doing whatever. I had been using a system where the 52wks are sandwhiched between 2 sheets : 1 called "First" and the other called "Last", then any summation was simply : =SUM(First:Last!A1) This has worked well, but I would like to be able to change the
    function so that it only reflects the time accumulated up to the current week
    ie. =SUM(First:Week5!A1) this way as you reach the end of the year and look back to any given week the time calculated is only the time to that week.

    I have been able to extract the current week from the sheet tab, but cannot get the sysntax correct to call this from the SUM function. I have stored the sheet name to a cell such as A1, then substituted into :
    =SUM("First:'"&A1&"'!B25") ..this does not work, and have tried experimenting with the quotes..no luck.
    as well : =SUM("First:'"MID(CELL("Filename"),SEARCH("]",CELL("Filename"),1)+1,32)"'!B25")

    Again, no luck. I know this is a simple problem, but I can't seem to find an answer. Can anyone see what is wrong with my syntax ?

    Many Thanks for any pointers, Wally

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Help with argument substitution in SUM

    I think that your current solution is probably going to be the answer without some complex VBA.

    Also, look at this example if you are looking to only carve out one week. (attached)

    Alan
    Attached Files Attached Files
    Last edited by alansidman; 12-23-2010 at 11:04 PM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Argument substitution in SUM

    Unfortunately you can not create a 3D reference per your original post.

    A more common approach would be to list all relevant sheets and then use a SUMPRODUCT & INDIRECT approach, however, if you wish to revise the listing regularly this may prove cumbersome (not to mention inefficient)

    Another alternative would be to use Names and Evaluate XLM call.

    Let's say in A1 you have the last sheet and in B1 you have the cell reference you wish to SUM - with B1 the active cell create the following Names:

    Please Login or Register  to view this content.
    in C1 you can then retrieve the result

    Please Login or Register  to view this content.
    again, the above is not particularly practical.

    I confess I would err towards a basic UDF

    Please Login or Register  to view this content.
    invoked from a cell:

    Please Login or Register  to view this content.
    so in essence you build the formula string and then use the UDF to execute as though a physical reference.
    Last edited by DonkeyOte; 12-24-2010 at 06:00 AM. Reason: typo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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