+ Reply to Thread
Results 1 to 6 of 6

Formula to calculate sum of column range based on presence of value in another column

  1. #1
    Registered User
    Join Date
    09-23-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    19

    Formula to calculate sum of column range based on presence of value in another column

    Hi all,

    I've been trying for some time to setup a formula that sums a column range based on the presence of the value "NULL" in another column, which defines the row range.
    I'm looking for the sum of Quantity (Column B) for cells in rows between NULL labels in Column A. The sum is to be captured in Column C, one row above the row with "NULL" value.
    Problem is that the number of rows between "NULL" values varies, hence any formula I guess would need to be dynamic in some way.

    See below example:

    Example:

    A B C
    Value Quantity Sum
    NULL 0
    [time 1] 1
    [time 2] 0
    [time 3] 1
    [time 4] 0 2
    NULL 0
    [time 5] 0
    [time 6] 1
    [time 7] 1
    [time 8] 1
    [time 9] 0 3
    NULL
    ....
    ....


    I've attached a sheet which might make my query easier to understand.

    Any advice/help would be really appreciated!

    Many thanks,

    Allard
    Attached Files Attached Files

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Formula to calculate sum of column range based on presence of value in another column

    Try this formula in C2 copied down

    =IF(A3="Null",SUM(B$1:B2)-SUM(C1:C$1),"")
    Audere est facere

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Formula to calculate sum of column range based on presence of value in another column

    Hi Allard,

    Here's a VBA routine:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    09-23-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    19

    Smile Re: Formula to calculate sum of column range based on presence of value in another column

    Brilliant Daddylonglegs! This works fine,many thanks

  5. #5
    Registered User
    Join Date
    09-23-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Formula to calculate sum of column range based on presence of value in another column

    Thanks Daddylonglegs & XLAdept!

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Formula to calculate sum of column range based on presence of value in another column

    You're welcome!

+ 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