Excel hacks tips & tools for streamlining your spreadsheets o'reilly 2007

Page 226

HACK

Sum or Count Cells While Avoiding Error Values

H A C K

#79

Sum or Count Cells While Avoiding Error Values

Hack #79

Error values are useful warnings, but sometimes you need to do calculations despite the errors. Choosing functions that tolerate errors will let you do this.

When a range of cells contains one or more error values, most formulas that reference that range of cells also will return an error. You can overcome this frustration by using the DSUM function. Assume you have a long list of numbers for which you need to get the sum total. However, one of the cells, for whatever reason, is returning the #N/A error. Set up some data such as that shown in Figure 6-8.

Figure 6-8. Data set up to generate #N/A error message

To generate the #N/A error, enter the formula =NA( ) in cells A2 and B2. Cell A12 uses a standard SUM function that sums cells A2:A11, and because cell A2 has the #N/A error, the SUM function also returns #N/A. The range D1: D2 has been named Criteria and is used as the last argument in the DSUM function, which resides in cell B12. The syntax for the DSUM function (and all the database functions) is as follows: =DSUM(database,field,criteria)

The database argument identifies the range of cells that comprise the list or database. Within the database range, rows of related information are treated as records, while columns of data are treated as fields. The first row contains labels for all the columns.

Chapter 6, Hacking Formulas and Functions |

203

#79


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.