Chapter 14. Everyday Functions

Understanding Mathematical Functions

Understanding Text Functions

Understanding Logical Functions

Understanding Information Functions

Understanding Lookup and Reference Functions

THIS chapter describes some of the more useful functions Microsoft Excel 2010 has to offer. To keep this book from threatening the structural integrity of your bookshelf, we’ve had to make some hard choices about which functions to highlight. Therefore, this chapter (along with Chapters Chapter 15, Chapter 16, and Chapter 17) by no means represents a comprehensive reference. For complete information about all the built-in functions that Excel 2010 has to offer, you can use a number of on-screen tools, which are covered in Using the Built-In Function Reference in Excel on page 527. Appendix C, lists every function available in Excel, along with the basic information you need to put each one to use, and includes cross-references to any information available in this and other chapters.

Note

For more information, see Chapter 15, Chapter 16 and Chapter 17.

Most of the work you do in Excel probably involves at least a few mathematical functions. The most popular among these is the SUM function, but Excel is capable of calculating just about anything. In the next sections, we discuss some of the most used (and most useful) mathematical functions in Excel.

The SUM function totals a series of numbers. It takes the form =SUM(number1, number2, …). The number arguments are a series of as many as 30 entries that can be numbers, formulas, ranges, or cell references that result in numbers. SUM ignores arguments that refer to text values, logical values, or blank cells.

image with no caption

Because SUM is such a commonly used function, Excel provides the Sum button on the Home tab on the ribbon, as well as the AutoSum button on the Formulas tab. In addition to SUM, these buttons include a menu of other commonly used functions. If you select a cell and click the Sum button, Excel creates a SUM formula and guesses which cells you want to total. To enter SUM formulas in a range of cells, select the cells before clicking Sum.

The SUMIF function is similar to SUM, but it first tests each cell using a specified conditional test before adding it to the total. This function takes the arguments (range, criteria, sum_range). The range argument specifies the range you want to test, the criteria argument specifies the conditional test to be performed on each cell in the range, and the sum_range argument specifies the cells to be totaled. For example, if you have a worksheet with a column of month names defined using the range name Months and an adjacent column of numbers named Sales, use the formula =SUMIF(Months, “June”, Sales) to return the value in the Sales cell that is adjacent to the label June. Alternatively, you can use a conditional test formula such as =SUMIF(Sales, “>=999”, Sales) to return the total of all sales figures that are more than $999.

The SUMIFS function does similar work to that of the SUMIF function, except you can specify up to 127 different ranges to sum, each with their own criteria. Note that in this function, the sum_range argument is in the first position instead of the third position: (sum_range, criteria_range1, criteria1, criteria_range2, criteria2, …). The sum range and each criteria range must all be the same size and shape. Using a similar example to the one we used for the SUMIF function, suppose we also created defined names for cell ranges Months, Totals, Product1, Product2, and so on. The formula =SUMIFS(Totals, Product3, “<=124”, Months, “June”) returns the total sales for the month of June when sales of Product3 were less than or equal to $124.

Similarly, COUNTIF counts the cells that match specified criteria and takes the arguments (range, criteria). Using the same example, you can find the number of months in which total sales fell to less than $600 by using a conditional test, as in the formula =COUNTIF(Totals, “<600”).

image with no caption

Excel has over 60 built-in math and trigonometry functions; the following sections brush only the surface, covering a few of the more useful or misunderstood functions. You can access them directly by clicking the Math & Trig button on the Formulas tab on the ribbon.

The RAND function generates a random number between 0 and 1. It’s one of the few Excel functions that doesn’t take an argument, but you must still type a pair of parentheses after the function name. The result of a RAND function changes each time you recalculate your worksheet. This is called a volatile function. If you use automatic recalculation, the value of the RAND function changes each time you make a worksheet entry.

The RANDBETWEEN function provides more control than RAND. With RANDBETWEEN, you can specify a range of numbers within which to generate random integer values. The arguments (bottom, top) represent the smallest and largest integers that the function should use. The values for these arguments are inclusive. For example, the formula =RANDBETWEEN(123, 456) can return any integer from 123 up to and including 456.

Excel includes several functions devoted to the seemingly narrow task of rounding numbers by a specified amount.

The FLOOR function rounds a number down to its nearest given multiple, and the CEILING function rounds a number up to its nearest given multiple. These functions take the arguments (number, multiple). For example, the formula =FLOOR(23.4, 0.5) returns 23, and the formula =CEILING(5, 1.5) returns 6, the nearest multiple of 1.5. The FLOOR.PRECISE and CEILING.PRECISE functions (both new in Excel 2010) round numbers down or up to the nearest integer or multiple of significance. Both take the arguments (number, significance). For example, the formula =FLOOR.PRECISE(23.4, 4) returns 20, which is the nearest integer below 23.4 that is a multiple of 4. Most of the time, you see no difference in results between the regular and precise versions of these functions, unless your arguments are negative numbers. The precise versions always round up, regardless of the number’s sign.