+ Reply to Thread
Results 1 to 4 of 4

Sum Variable Range

  1. #1
    Registered User
    Join Date
    09-14-2004
    MS-Off Ver
    2010
    Posts
    30

    Sum Variable Range

    Assuming the given data (in the image at the link below), is there a formula that I can put into D3 that will sum a given number of cells based on the value in cell D2? I can't do this with if statements because my actual data has 20 columns, and dozens of rows. (The formulas would actually be in the same row as the data, and it would be summing part of the row... and this would be repeated on each row for alternate data.)

    Basically if I put 2 in I want it to sum(a6:b6), if I have 5 in D2, then I want D3 to sum(a6:e6).

    I know I can figure this out easy enough with VBA, but I was wondering if there's a way to do it with a formula?
    \1
    Last edited by DonkeyOte; 01-08-2011 at 05:55 AM. Reason: Issue solved. mod: title edit

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,995

    Re: Is there a formula that can do this?

    =SUM(A6:OFFSET(A6,,,1,D2))

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-14-2004
    MS-Off Ver
    2010
    Posts
    30

    Re: Is there a formula that can do this?

    Thank you very much!

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

    Re: Is there a formula that can do this?

    @Fizziii, glad you resolved and welcome to the board.

    Going forward please ensure your thread title relates to the underlying problem - eg: sum variable range

    FWIW you can also use:

    Please Login or Register  to view this content.
    which is non volatile (unlike OFFSET) ... also with the above should you set D2 as 0 it will sum the entire row.

+ 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