Page 360 - Excel 2013 All-in-One For Dummies
P. 360
342 Error-Trapping Formulas
In this formula, Excel first evaluates the first logical argument to determine whether the contents in cell B5 and D10 are equal to each other. If they are, the first comparison returns TRUE. If they are not equal to each other, this comparison returns FALSE. The program then evaluates the second logical argument to determine whether the content of cell C15 is greater than or equal to 500. If it is, the second comparison returns TRUE. If it is not greater than or equal to 500, this comparison returns FALSE.
After evaluating the comparisons in the two logical arguments, the AND func- tion compares the results: If logical argument 1 and logical argument 2 are both found to be TRUE, the AND function returns logical TRUE to the cell.
If, however, either argument is found to be FALSE, the AND function returns FALSE to the cell.
When you use the IF function, you specify what’s called a logical_test argu- ment whose outcome determines whether the value_if_true or value_if_false argument is evaluated and returned to the cell. The logical_test argument normally uses comparison operators, which return either the logical TRUE or logical FALSE value. When the argument returns TRUE, the entry or expression in the value_if_true argument is used and returned to the cell. When the argument returns FALSE, the entry or expression in the value_if_ false argument is used.
Consider the following formula that uses the IF function to determine whether to charge tax on an item:
=IF(E5=”Yes”,D5+D5*7.5%,D5)
If cell E5 (the first cell in the column where you indicate whether the item being sold is taxable or not) contains “Yes,” the IF function uses the value_ if_true argument that tells Excel to add the extended price entered in cell D5, multiply it by a tax rate of 7.5%, and then add the computed tax to the extended price. If, however, cell D5 is blank or contains anything other than the text “Yes,” the IF function uses the value_if_false argument, which tells Excel to just return the extended price to cell D5 without adding any tax to it.
As you can see, the value_if_true and value_if_false arguments of the IF func- tion can contain constants or expressions whose results are returned to the cell that holds the IF formula.
Error-Trapping Formulas
Sometimes, you know ahead of time that certain error values are unavoid- able in a worksheet as long as it’s missing certain data. The most common