18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Part II<br />

Working with Formulas and Functions<br />

About This Chapter’s Examples<br />

Most of the examples in this chapter use named ranges for function arguments. When you adapt these formulas<br />

for your own use, you’ll need to substitute either the actual range address or a range name<br />

defined in your workbook.<br />

Also, some examples consist of array formulas. An array formula is a special type of formula that enables you<br />

to perform calculations that would not otherwise be possible. You can spot an array formula because it’s<br />

enclosed in curly brackets when it’s displayed in the Formula bar. In addition, I use this syntax for the array<br />

formula examples presented in this book. For example:<br />

{=Data*2}<br />

When you enter an array formula, press Ctrl+Shift+Enter (not just Enter) and don’t type the brackets. (Excel<br />

inserts the brackets for you.) If you need to edit an array formula, don’t forget to use Ctrl+Shift+Enter when<br />

you’ve finished editing (otherwise, the array formula will revert to a normal formula and it will return an<br />

incorrect result). Refer to Chapter 17 for an introduction to array formulas.<br />

Counting the total number of cells<br />

To get a count of the total number of cells in a range (empty and non-empty cells), use the following formula.<br />

This formula returns the number of cells in a range named Data. It simply multiplies the number of<br />

rows (returned by the ROWS function) by the number of columns (returned by the COLUMNS function).<br />

=ROWS(Data)*COLUMNS(Data)<br />

This formula will not work if the Data range consists of noncontiguous cells. In other words, Data must be a<br />

rectangular range of cells.<br />

Counting blank cells<br />

The following formula returns the number of blank (empty) cells in a range named Data:<br />

=COUNTBLANK(Data)<br />

The COUNTBLANK function also counts cells containing a formula that returns an empty string. For example,<br />

the formula that follows returns an empty string if the value in cell A1 is greater than 5. If the cell meets<br />

this condition, the COUNTBLANK function counts that cell.<br />

=IF(A1>5,””,A1)<br />

You can use the COUNTBLANK function with an argument that consists of entire rows or columns. For<br />

example, this next formula returns the number of blank cells in column A:<br />

=COUNTBLANK(A:A)<br />

The following formula returns the number of empty cells on the entire worksheet named Sheet1. You must<br />

enter this formula on a sheet other than Sheet1, or it will create a circular reference.<br />

=COUNTBLANK(Sheet1!1:1048576)<br />

252

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!