In excel adding a range with one condition can be done with conditional formula called sumif. The conditional sum worksheet function sumif adds the specified range based on the criteria. The sumif conditional sum accepts only one criteria. If you want to perform sum based on multiple criteria, then you need to use multi conditional sum formula sumifs.
Syntax of conditional sum sumif Worksheet Function
Syntax: =SUMIF(range, criteria, [sum_range]).
Range: The range of cells that you want evaluated by criteria. Cells in each range must be numbers or names, arrays, or references that contain numbers. Blank and text values are ignored.
Criteria: The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. For example, criteria can be expressed as 32, “>32”, B5, 32, “32”, “apples”, or TODAY().
Important Note: Any text criteria or any criteria that includes logical or mathematical symbols must be enclosed in double quotation marks (“). If the criteria is numeric, double quotation marks are not required.
sum_range:The actual cells to add, if you want to add cells other than those specified in the range argument. If the sum_range argument is omitted, Excel adds the cells that are specified in the range argument (the same cells to which the criteria is applied).
Note: If you dont define sumrange then excel adds the range based on criteria. sumrange is needed if you want add other than criteria range.
Examples for sumif worksheet function
Below are the example for conditional sum in excel.
So sumif excel formula to add only Apple is
If you are having multiple criteria for sum then you should use multiconditional sum refer to my previous post on multiconditional sum.
You can also use Wild card charectors with SUMIF function. In that way you can even extend the usage of SUMIF functions.