+ Reply to Thread
Results 1 to 9 of 9

Progressive Sum Based on Variable.

  1. #1
    Forum Contributor
    Join Date
    06-29-2008
    Location
    Grand Rapids, MI
    MS-Off Ver
    Office 2010
    Posts
    127

    Progressive Sum Based on Variable.

    ok, this may be the same answer as the previous post i did, but if so, i can't figure that part out.

    In O2, if M2 = 8, and N2 = 2008, then add O3 + 8 rows (O3:O10)

    or, if M2 = 5, and N2 = 2009 then add O16 + 5 rows (O16:O20).

    I'm ready for a simple solution that I don't understand, lol.
    Attached Files Attached Files
    Last edited by robert_shindorf; 01-26-2009 at 05:58 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482
    Try,
    =IF(AND(M2=8,N2=2008),SUM(O3:O10),IF(AND(M2=5,N2=2009),SUM(O16:O20),""))

  3. #3
    Forum Contributor
    Join Date
    06-29-2008
    Location
    Grand Rapids, MI
    MS-Off Ver
    Office 2010
    Posts
    127
    oops, i don't think i explained it properly...

    ok, m2 will vary, it's linked to a different worksheet.... and dependent on it's value, depends on the number of rows needed. (if it's a 3, 3 rows, it it's a 9, 9 rows).

    if it's 2008 in n2, then start counting the rows at o3, if it's 2009, then start at o16.

    does that make more sense... it's a little harder than that dave! but, you did solve what i said!

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    Not that I'm a fan of OFFSET given it's volatility but here it might be quite useful:

    =SUM(OFFSET($O$3,12*($N$2-2008),0,$M$2,1))

  5. #5
    Forum Contributor
    Join Date
    06-29-2008
    Location
    Grand Rapids, MI
    MS-Off Ver
    Office 2010
    Posts
    127
    hmmm... that didn't seem to work... i'm not too familiar with the offset function either, i copied and pasted it, directly into cell O2.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    change the 12* to 13*

    Post a sample of your file if the above does not resolve the issue.

  7. #7
    Forum Contributor
    Join Date
    06-29-2008
    Location
    Grand Rapids, MI
    MS-Off Ver
    Office 2010
    Posts
    127

    Re: Progressive Sum Based on Variable.

    ahhh, that worked with the 13...

    i don't understand how it works, if you wouldn't mind explaining it, i'd really appreciate it... thanks!

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

    Re: Progressive Sum Based on Variable.

    OFFSET(reference,rows,cols,height,width)

    traditionally OFFSET is use to reference another cell from a starting position by "offsetting" by x rows and x cols...

    eg

    =OFFSET(D4,3,3)

    would offset D4 by 3 rows and 3 columns - eg D4 -> G7 and return the result of that cell
    (row offset if < 0 goes "up" and col offset if <0 goes "left")

    Height & Width are used less often but essentially can be used to specify the size of the new range...

    =OFFSET(D4,3,3,10,2)

    would offset D4 as before to G7 but would create a new range 10 rows high and 2 columns wide, eg: G7:H16, however, when used in this context you need to "do something" with the range created... in your case SUM

    =SUM(OFFSET(D4,3,3,10,2))

    will SUM the contents of G7:H16

    So in your case the variables are the amount of rows by which you need to offset from O3 and the height of the new range... the row can be determined by multiplying 13 * (year - 2008) -- so if looking at 2009 you will offset from O3 by 13 rows, were the year 2010 you would offset by 26 rows... the height of the final range is determined by the value in M2.
    Last edited by DonkeyOte; 01-26-2009 at 06:11 PM.

  9. #9
    Forum Contributor
    Join Date
    06-29-2008
    Location
    Grand Rapids, MI
    MS-Off Ver
    Office 2010
    Posts
    127

    Re: Progressive Sum Based on Variable.

    ahhhh, that was a great explanation, and a great way to set a variable. thanks for the explanation!

+ 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