+ Reply to Thread
Results 1 to 6 of 6

conditional subtotal function

  1. #1
    Registered User
    Join Date
    08-19-2005
    Posts
    58

    conditional subtotal function

    i can't seem to get anything to work.

    the data appears as follows:

    Please Login or Register  to view this content.
    now, i have an autofilter that will filter some of these out and leave the rest, e.g.:

    Please Login or Register  to view this content.
    now i need to calculate a sum with the condition that the value in column a is "on". here, the answer should be 1400.

    the usual array formula with a sum doesn't work because it sums hidden cells as well. the only function i know of that sums correctly is the subtotal function, but i don't know how to add the "on"-only condition to it.

    any ideas? thanks.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483
    http://www.contextures.com/xlFunctions01.html

    Check this page for info to sum a filtered list

  3. #3
    Bob Phillips
    Guest

    Re: conditional subtotal function

    =SUMPRODUCT((SUBTOTAL(9,OFFSET($B$1,ROW($B$2:$B$20)-ROW($B$1),,1)))*(A2:A20=
    "ON"))

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "dreamz" <[email protected]> wrote in
    message news:[email protected]...
    >
    > i can't seem to get anything to work.
    >
    > the data appears as follows:
    >
    >
    > Code:
    > --------------------
    >
    > A B
    > ON 1000
    > ON 1000
    > OFF 500
    > OFF 500
    > ON 1000
    > OFF 1000
    > OFF 400
    > OFF 300
    > ON 400
    >
    > --------------------
    >
    >
    > now, i have an autofilter that will filter some of these out and leave
    > the rest, e.g.:
    >
    >
    > Code:
    > --------------------
    >
    > A B
    > OFF 500
    > OFF 500
    > ON 1000
    > OFF 1000
    > ON 400
    >
    > --------------------
    >
    >
    > now i need to calculate a sum with the condition that the value in
    > column a is "on". here, the answer should be 1400.
    >
    > the usual array formula with a sum doesn't work because it sums hidden
    > cells as well. the only function i know of that sums correctly is the
    > subtotal function, but i don't know how to add the "on"-only condition
    > to it.
    >
    > any ideas? thanks.
    >
    >
    > --
    > dreamz
    > ------------------------------------------------------------------------
    > dreamz's Profile:

    http://www.excelforum.com/member.php...o&userid=26462
    > View this thread: http://www.excelforum.com/showthread...hreadid=572446
    >




  4. #4
    Registered User
    Join Date
    08-19-2005
    Posts
    58
    thanks, dave! i'll be reading through that site to better understand the functions.

    bob, that worked perfectly. now to figure out exactly what it means. thanks again.

  5. #5
    Registered User
    Join Date
    09-18-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: conditional subtotal function

    Hello
    I have a similar problem and would very much appreciate any help.

    In the file attached TEST.xls there are main objects (Home) and within them there are two other objects (Cats and Dogs)
    Each of the objects (Home,Cat,Dog) has an area in m and a Home ID.

    My question is to calculate the total sum of area in m taken by cats from all the homes that have cats only and a total sum of area taken by cats from the homes that have both cats and dogs (excluding dog areas).

    This could be done by combining conditional sum (IF Name = "Cat*" and SUM column "Area") and subtotal (at each home ID change) functions in Excel. I've spend days trying to make it work.

    The provided example is rather short abbreviation. True files deals with hundreds of homes.

    Any suggestions are very much appreciated!

    Regards

    Sebastian

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: conditional subtotal function

    bastiano,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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