+ Reply to Thread
Results 1 to 5 of 5

Making a SUM formula with variable sum range

  1. #1
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Making a SUM formula with variable sum range

    Hi all,

    I'm looking for a way to make a SUM formula that shifts it's range (in a non-standard way) when I copy it to other cells.
    Each sum has a vertical range above it. The range of the sum 1 column to the right, should start 1 row lower (but end in the same row).
    The attached example file will probably make more sense than this explanation

    I've experimented with OFFSET, INDIRECT, MID("ABCD...";COLUMN(B3);1) etc etc but I can't get it right...
    Who can help me?

    Thanks a lot,
    Leon
    Attached Files Attached Files
    Last edited by L-Drr; 01-07-2018 at 09:18 AM. Reason: solved
    When I say semicolon, u say comma!

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,127

    Re: Making a SUM formula with variable sum range

    In B8, copied across:

    =SUM(OFFSET(B7,,,-5+(COLUMNS($A:A)-1),))
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Making a SUM formula with variable sum range

    Wow Glenn,

    There are so many thing in your formula I didn't know about
    But I managed to get it working in my actual file, so thanks a lot!!

    I've simplified it a little bit
    - merged your "-5+x-1" to "x-6" (although your version follows the line of thought)
    - changed your "COLUMNS($A:A)" to "COLUMN(A1)"

    I also didn't know you could leave the 2nd and 3rd argument in the OFFSET function empty; in the Dutch excel-help they seem te be mandatory
    I still don't fully understand how the OFFSET-part of the formula results in something like "B3:B7" as the only argument in the SUM formula, but hey, it works

    Once again thanks for providing the formula and teaching me a thing or two!

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,127

    Re: Making a SUM formula with variable sum range

    merged your "-5+x-1" to "x-6" (although your version follows the line of thought). Exactly why I set it out the way that I did. If look at it in 6 months time, you won't remember what you did... or why.

    To be really fussy, you should use:

    =SUM(OFFSET(B7,,,-5+(COLUMNS($B:B)-1),))

    in either your version, or my previous version.... delete column A and weep.

  5. #5
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Making a SUM formula with variable sum range

    Hahaha very true XD

+ 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. [SOLVED] Range formula with variable
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-20-2015, 04:29 AM
  2. Using a range variable in a formula
    By rachmanchester in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2014, 04:11 PM
  3. Making a variable range in VBA
    By royalB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2014, 02:33 PM
  4. [SOLVED] Use a variable in Range.Formula
    By jewelsharma in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 05:40 AM
  5. [SOLVED] Use variable range in a formula
    By Mumps1 in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 05-20-2013, 07:18 PM
  6. [SOLVED] Macro to sum a dynamic/variable range - I'm making this harder than it has to be, I think.
    By ajava in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-07-2012, 02:48 PM
  7. Range and Variable formula
    By tlm in forum Excel General
    Replies: 3
    Last Post: 02-10-2010, 03:20 PM

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