
407
Appendix A: When Your Worksheet Is a Database
Okay, I worked really hard to set up the premise for the preceding sentence.
Here are two examples that are easier to follow: I define Planet as the name of
cell C10, and Orbital_Period_Days as the name of D10, and so on. Now I can
use these field names in Excel’s database formulas.
The criteria range
I copied the column headers — excuse me, field names — into the top row. I
also put some information into nearby cells. This area is for the criteria range.
This range enables you to use Excel’s database functions to ask (and answer)
questions about the data. Database honchos call this “querying.” Criteria are
a part and parcel of each database function. (“Criteria” is plural. The singular
form is “criterion.”)
It’s not necessary to have this range at the top of the worksheet. You can des-
ignate any range in the worksheet as the criteria range.
When you use an Excel database function it’s in this format:
=FUNCTION(Database, Field, Criteria)
The function operates on the specified database, in the designated field,
according to the indicated criteria.
For example, if you want to know how many satellites revolve around Saturn,
you select a cell and enter
=DCOUNT(Satellites,Average_Distance_X_1000_km,C1:C2)
Here’s what this formula means: In the database (B1:G35), DCOUNT tallies up
the amount of number-containing cells in the Average_Distance_X_1000_km
field, constrained by the criterion specified in the cell range C1:C2. That cri-
terion is equivalent to Planet = Saturn. Note that a criterion has to include at
least one column header . . . uh . . . field name from the criteria range, and at
least one row. Bear in mind that you can’t use the actual field name in the cri-
teria. You use the cell ID (like C1).
When you include more than one row, you’re saying “or.” For example, if
your criterion happens to be G1:G3, you’re specifying satellites discovered by
Galileo or Cassini.
When you include more than one column in a criterion, you’re saying “and.”
If your criterion is E1:F2, you’re specifying satellites farther than 150,000 km
from their planets and discovered after 1877.
29 454060-bapp01.indd 40729 454060-bapp01.indd 407 4/21/09 7:39:36 PM4/21/09 7:39:36 PM