+ Reply to Thread
Results 1 to 8 of 8

Thread: Increase range by one using a dynamic range

  1. #1
    Forum Guru jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    2,573

    Increase range by one using a dynamic range

    If you notice on the attachment in columns I:J I am summing up at each change in the word Major in column I.

    Instead of the hard coding the range I would like to make the range dynamic, but not sure how to increase the range by one.

    Here is at least one part of the formula

    SUM($J3:$J$14)

    which to make dynamic I have gone with

    SUM($J3:INDEX(J:J,MATCH(BigNum,J:J))

    but this only returns

    SUM($J3:$J$13)

    but I need it to be down to the last row +1 which equals $J$14
    Attached Files Attached Files
    Last edited by jeffreybrown; 03-02-2011 at 03:45 PM.
    HTH
    Regards, Jeff

    If you like the answer(s) provided, why not add some reputation by clicking the * below
    Please use [ Code ] tags when posting [ /Code ]
    Please view/read the Forum rules --- How to mark a thread as solved

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Increase range by one using a dynamic range

    So wouldn't that be?

    =SUM($J3:INDEX(J:J,MATCH(BigNum,J:J)+1))
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Forum Guru jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    2,573

    Re: Increase range by one using a dynamic range

    Thanks NBVC,

    That's what I thought it would be, but the result retuns a zero.

    When I step through the formula it shows the correct result, but the outcome only displays zero.

    Also, when I drag the fomula down I get a circular reference at E8

    =IF($D2="Major",IF(COUNTIF($D3:INDEX(D:D,MATCH(REPT("z",255),D:D)+1),"Major"),
    SUM($E3:INDEX($E3:INDEX(E:E,MATCH(BigNum,E:E)+1),MATCH("Major",$D3:INDEX(D:D,MATCH(REPT("z",255),D:D )+1),0)-1)),SUM($E3:INDEX(E:E,MATCH(BigNum,E:E)+1))),C2)
    HTH
    Regards, Jeff

    If you like the answer(s) provided, why not add some reputation by clicking the * below
    Please use [ Code ] tags when posting [ /Code ]
    Please view/read the Forum rules --- How to mark a thread as solved

  4. #4
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Increase range by one using a dynamic range

    Does this work?

    =IF(D2="Major",SUM(C3:INDEX($C3:$C$14,MATCH(TRUE,INDEX($C3:$C$14="",0),0))),C2)
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  5. #5
    Forum Guru jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    2,573

    Re: Increase range by one using a dynamic range

    Yes NBVC this seems to work fine. I tried it the way you provided and then expanded in to be dynamic with:

    =IF(D2="Major",SUM(C3:INDEX($C3:INDEX(C:C,MATCH(BigNum,C:C)+1),MATCH(TRUE,INDEX($C3:INDEX(C:C,MATCH( BigNum,C:C)+1)="",0),0))),C2)

    I will try to implement this on my project now...much appreciated
    HTH
    Regards, Jeff

    If you like the answer(s) provided, why not add some reputation by clicking the * below
    Please use [ Code ] tags when posting [ /Code ]
    Please view/read the Forum rules --- How to mark a thread as solved

  6. #6
    Forum Guru jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    2,573

    Re: Increase range by one using a dynamic range

    Hi again NBVC,

    This will work if I had an additional column, but I am stuck with the format of the spreadsheet so therefore all should be summed in one column.

    I should have made the example different, ex., column C is not one value as displayed it is a multiplication of two cells.

    So in the example it could be considered B2 * C2.

    Instead of using column C I was hoping to use column E where I can sum up all of the Sub's between the Major's so E2 will be the sum of all the Sub's inbetween Major's or if D2 equals Major then B2*C2.

    My only other alternative was to use

    =IF($D2="Major",
    IF(COUNTIF($D3:$D$14,"Major"),
    SUM($E3:INDEX($E3:$E$14,MATCH("Major",$D3:$D$14,0)-1)),
    SUM($E3:$E$14)),B2*C2)

    and make the E14 and D14 something like 2000 which should cover the entire range.

    Hope this helps
    Last edited by jeffreybrown; 03-02-2011 at 09:56 AM.
    HTH
    Regards, Jeff

    If you like the answer(s) provided, why not add some reputation by clicking the * below
    Please use [ Code ] tags when posting [ /Code ]
    Please view/read the Forum rules --- How to mark a thread as solved

  7. #7
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Increase range by one using a dynamic range

    How about?

    =IF(D2="Major",SUM(E3:INDEX($E3:$E$14,MATCH(1,INDEX(($D3:$D$14="")+($D3:$D$14="Major"),0),0)-1)),B2*C2)
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  8. #8
    Forum Guru jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    2,573

    Re: Increase range by one using a dynamic range

    NBVC,

    Thank you for your patience, it seems to be working now. All the best...
    HTH
    Regards, Jeff

    If you like the answer(s) provided, why not add some reputation by clicking the * below
    Please use [ Code ] tags when posting [ /Code ]
    Please view/read the Forum rules --- How to mark a thread as solved

+ 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.2.0