+ Reply to Thread
Results 1 to 8 of 8

Subtotal based on Cell condition

  1. #1
    Forum Contributor
    Join Date
    02-23-2007
    Location
    England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2208 Build 16.0.15601.20072) 64-bit
    Posts
    102

    Subtotal based on Cell condition

    Hello All

    I have a spreadsheet where column B contains the number of products, C contains the words "consecutive" and "consecutive end" and column E contains the amount. I have attached a mock up for clarity.

    What I would like is a formula (or VB) to add a subtotal in column F, so that the formula is totalling up until (and including) it reaches the cell called "consecutive end", then I want the formula to calculate the next subtotal. Hopefully the attached will make more sense.

    Any help much appreciated.

    Many thanks
    G1
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Subtotal based on Cell condition

    Could you explain in more detail at least the first 9 in cell A5? I'm not understanding how you get to 9.
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    02-23-2007
    Location
    England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2208 Build 16.0.15601.20072) 64-bit
    Posts
    102

    Re: Subtotal based on Cell condition

    Hello Jeff

    Apologies for the delay.

    What is want is for the cells in column F to display a sub total, in line with where cells in column C display "Consecutive End". So in the case of the result in F5 in my attachment I tried to formulate:

    F5 = the sum of (B3 x E3) + (B4 x E4) + (B5 x E5).

    F5 shows the subtotal because C5 displays "Consecutive End". I need this to loop through the rest of the table.

    I hope this makes more sense of my nonsense, and I am open to better ways to calculate this from you.

    Many thanks
    G1

  4. #4
    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
    44,447

    Re: Subtotal based on Cell condition

    You could do a running total, for example,
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    And, you can use Conditional Formatting to hide the values on the "Consecutive" lines.

    I think you need some way of building up the subtotals. Other than that, I suspect it would be a messy formula.
    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


  5. #5
    Forum Contributor
    Join Date
    02-23-2007
    Location
    England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2208 Build 16.0.15601.20072) 64-bit
    Posts
    102

    Re: Subtotal based on Cell condition

    Thank you TMS, I will give that a try as I think you are right; I need to remember that Excel is a program and not capable of thinking like a human, so the code to do this would indeed be messy.

    Thanks again
    G1

  6. #6
    Forum Contributor
    Join Date
    02-23-2007
    Location
    England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2208 Build 16.0.15601.20072) 64-bit
    Posts
    102

    Re: Subtotal based on Cell condition

    Thank you TMS, I will give that a try as I think you are right; I need to remember that Excel is a program and not capable of thinking like a human, so the code to do this would indeed be messy.

    Thanks again
    G1

  7. #7
    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
    44,447

    Re: Subtotal based on Cell condition

    You're welcome. Thanks for the rep.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Subtotal based on Cell condition

    After much trial and error (mostly error) an afterthought.

    This needs a helper column. In column A

    =B3*E3

    And a helper cell in C2 that says Consecutive END.

    Then array-entered in G3 and filled down.

    =IF(C3="Consecutive END",SUM(INDEX($A$2:A3,MATCH(2,1/($C$2:C2="Consecutive END"),1)+1):INDEX($A$2:A3,ROW()-ROW($3:$3)+2)),"")

    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Attached Files Attached Files
    Last edited by FlameRetired; 05-18-2016 at 11:00 PM. Reason: Additional detail
    Dave

+ 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] How to subtotal based on cell color?
    By alexduy in forum Excel General
    Replies: 7
    Last Post: 08-27-2014, 11:34 PM
  2. VBA - Subtotal based on cell color
    By The Fly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-08-2014, 11:42 AM
  3. Subtotal VBA based on spaces at start of Cell
    By cockneyreject in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2014, 12:56 PM
  4. Subtotal based on filtered list with more than one condition
    By efernandes67 in forum Excel General
    Replies: 5
    Last Post: 08-22-2012, 04:00 AM
  5. Replies: 2
    Last Post: 06-20-2012, 09:31 AM
  6. Select worksheet based on condition & populate cell based on condition
    By beth1069 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2011, 01:27 PM
  7. Subtotal condition
    By noodles in forum Excel General
    Replies: 3
    Last Post: 08-13-2009, 02:43 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