|
|
Subject:
Excel Conditional Subtotal Formula
Category: Computers > Algorithms Asked by: hammerhead222-ga List Price: $15.00 |
Posted:
09 Jul 2004 13:02 PDT
Expires: 08 Aug 2004 13:02 PDT Question ID: 372000 |
I want an excel formula that will subtotal a column of numbers if certain conditions are met. Using the subtotal function, (because I have hidden rows, and am using filtering) calculate the average of numbers that are not outliers or invalid (text, #value errors, etc.) For example In a spreadsheet that has 300 rows, and rows 150 through 155 are visible These numbers appear: 24 450 13 20 40 Calculate the average of the values that are less than 80 The answer should be 24.25 (97 / 4), not 109.4 (547 / 5) I have experience with the SUBTOTAL function, and I can sum, count, average the correct cells, but dont seem to be able to add conditions (such as, if the value is <80 or >0, etc.). I DO NOT want to have fixed formulas (like an array only for cells 155:160)that require me to select rows 155:160, because I may want to filter on rows 133:175 next time, so the SUBTOTAL formula (or an equivalent) is important. I dont know much about VBA and Macros, so if the answer can fit into a cell, that would be great Thank you | |
|
|
There is no answer at this time. |
|
Subject:
Re: Excel Conditional Subtotal Formula
From: iagt-ga on 09 Jul 2004 21:21 PDT |
Hello, just lurking and I think I have an answer for you... Use the sumif and countif functions... =SUMIF(A1:A5,"<80")/COUNTIF(A1:A5,"<80") The criteria reference can be to an input cell or other calculated result. Good luck. |
Subject:
Re: Excel Conditional Subtotal Formula
From: sebastienm-ga on 11 Jul 2004 01:54 PDT |
Hi, The main issue here is to compute on visible rows only. Besides SUBTOTAL, i don't think there is any other function. Working with multiple criteria is not a problem. The SUMIF function totals hidden and visible rows, and for 1 criterion only. The SUMPRODUCT totals hidden and visible rows with multiple criteria: (1) = SUMPRODUCT ( (A1:A10<80) * (A1:A10>0) * (B1:B10) ) --> sum (B1:B10) where 0<A1:A10<80 or (2) = SUMPRODUCT ( (A1:A10<80) * (A1:A10>0) * (B1:B10) ) / = SUMPRODUCT ( (A1:A10<80) * (A1:A10>0) * 1 ) ---> average of B1:B10 for rows where 0<A1:A10<80 Maybe a solution would be to look into defining the range to be summed based on visble rows only, say VisRange that named range based on column A: (1) = SUMPRODUCT ( (VisRange<80) * (VisRange>0) * (OFFSET(VisRange,0,1)) ) To define VisRange, maybe look into Excel4 macro type. Many of these functions cannot be used directly but some can be used as an expression of a named range. Try defining VisRange this way. I'll look into it next week when i have time. Regards, Sebastien |
Subject:
Re: Excel Conditional Subtotal Formula
From: gareththewormevans-ga on 12 Jul 2004 01:54 PDT |
My suggestion would be to use another column to slect the numbers that are <80. In column B enter the formula =if(a1<80,a1,"") Then you can do the calculation using this column (which can be hidden)! Don't know if this'll suit your needs though! Cheers! |
Subject:
Re: Excel Conditional Subtotal Formula
From: cmaury-ga on 12 Jul 2004 09:57 PDT |
Don't know what version of Excel you're using, but it looks like you're best served by using a macro. At least, that's what Microsoft says :) "How to Use a VBA Macro to Sum Only Visible Cells" http://support.microsoft.com/?kbid=150363 Should be straight forward. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |