+ Reply to Thread
Results 1 to 9 of 9

Sum column based on variable start and variable end months

  1. #1
    Forum Contributor Steve N.'s Avatar
    Join Date
    12-22-2011
    Location
    USA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    298

    Sum column based on variable start and variable end months

    Greetings...

    I'm trying to learn to sum portions of columns for different Shops based on a variable start and a variable end month.

    Can't seem to get my head around this one...

    The attached file shows a sample of the data I'm working with.

    Thanks in advance!

    Steve

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Sum column based on variable start and variable end months

    Based on your sample data, here's my attempt...

    =IFERROR(SUM(OFFSET($C$1,MATCH($L$2,$C$2:$C$12,0),MATCH(O1,$D$1:$I$1,0),MATCH($L$4,$C$2:$C$12,0)-MATCH($L$2,$C$2:$C$12,0)+1)),"")
    HTH
    Regards, Jeff

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Sum column based on variable start and variable end months

    its much easier if you put in a real date say first of each month and format as mmm then excel can use the values
    =SUMPRODUCT(($C$2:$C$20>=$L$2)*($C$2:$C$20<=eomonth($L$4,0)),D$2:D$20) you can probaby do this with sumifs but im not on my 2007 pc at the moment
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sum column based on variable start and variable end months

    and my aattenpt, I changed your "months" to dates, and then used this, copied across and down - see attached...
    =SUMIFS(OFFSET($C$1,1,MATCH(O$1,$D$1:$I$1,0),COUNT(D:D),1),$C$2:$C$12,">="&$L$2,$C$2:$C$12,"<="&$L$4)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Sum column based on variable start and variable end months

    whats all the offset about? 2 solutions with offset have i missed something obvious?

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Sum column based on variable start and variable end months

    Quote Originally Posted by martindwilson View Post
    its much easier if you put in a real date say first of each month and format as mmm then excel can use the values
    As Martin so wisely points out, here is another attempt without OFFSET and just a slight change to column C.

    =SUMIFS(INDEX($D$2:$I$12,,MATCH(O$1,$D$1:$I$1,0)),$C$2:$C$12,">="&$L$2,$C$2:$C$12,"<="&$L$4)

  7. #7
    Forum Contributor Steve N.'s Avatar
    Join Date
    12-22-2011
    Location
    USA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    298

    Re: Sum column based on variable start and variable end months

    Everyone of these work perfectly! Thank you all.

    How do I get that smart...?

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Sum column based on variable start and variable end months

    You are very welcome Steve and thanks for the feedback.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sum column based on variable start and variable end months

    Happy to help Steve and 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)

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