The Excel Sumif function finds the values in a supplied array, that satisfy a given criteria, and returns the sum of the corresponding values in a second supplied array.
The syntax of the function is:
where the function arguments are:
range    An array of values (or range of cells containing values) to be tested against the supplied criteria. 
criteria    The condition to be tested against each of the values in the supplied range. 
[sum_range]   
An optional array of numeric values (or cells containing numeric values), which are to be added together, if the corresponding range entry satisfies the supplied criteria. If the [sum_range] argument is omitted, the values from the range argument are summed instead. 
Wildcards
The following wildcards can be used in textrelated criteria:
?  matches any single character
*  matches any sequence of characters
(if you do actually want to find the ? or * character, type the ~ symbol before this character in your search.)
E.g. the condition "A*e" will match all cells containing a text string beginning with "A" and ending in "e".The supplied criteria argument can be either:
Note that:
The following spreadsheet shows three examples of the Excel Sumif function used with text based critia.
For each call to the Excel Sumif function, the range argument (to be tested against the criteria) is either the cell range A2A9 or the cell range B2B9, and the [sum_range] argument (containing the values to be summed) is the cell range C2C9.
Formulas:

Results:

Note that, in the example above:
The following example shows the Excel Sumif function using critia based on numeric values.
Formulas:

Results:

Note that, in the above spreadsheet:
For further examples of the Excel Sumif function, see the Microsoft Office website.
If you get an error from the Excel Sumif function, this is likely to be the #VALUE! error:
#VALUE!    Occurs if the supplied criteria is a text string that is more than 255 characters long. 