Vous êtes sur la page 1sur 5

Chapter 9: Tables and Worksheet Databases 245

duplicate search. Most of the time, you’ll want to select all the columns, which is the default. Click
OK, and Excel then weeds out the duplicate rows and displays a message that tells you how
many duplicates it removed.
Unfortunately, Excel does not provide a way for you to review the duplicate records before delet-
ing them. You can, however, use Undo (or press Ctrl+Z) if the result isn’t what you expect.

If you want to remove duplicates from a worksheet database that’s not a table, choose
Data➜Data Tools➜Remove Duplicates.

Figure 9-5: Removing duplicate rows from a table is easy.

Duplicate values are determined by the value displayed in the cell — not necessarily the
value stored in the cell. For example, assume that two cells contain the same date. One
of the dates is formatted to display as 5/15/2010, and the other is formatted to display
as May 15, 2010. When removing duplicates, Excel considers these dates to be different.

Sorting and filtering a table


Each column in the Header row of a table contains a clickable control, which normally displays a
downward pointing arrow. That control, when clicked, displays sorting and filtering options.
Figure 9-6 shows a table of real estate listing information after clicking the control for the Date
Listed column. If a column is filtered or sorted, the image on the control changes to remind you
that the column was used in a filter or sort operation.

This workbook, named real estate table.xlsx, is available on the companion


CD-ROM.

If you’re working with a worksheet database (rather than a table), use Data➜Sort &
Filter➜Filter to add the drop-down controls to the top row of your database. This com-
mand is a toggle, so you can hide the drop-down arrows by selecting that command
again. You can also use Data➜Sort & Filter➜Filter to hide the drop-down arrows in a
table.

14_475362-ch09.indd 245 4/14/10 10:09 PM


246 Part II: Using Functions in Your Formulas

Figure 9-6: Each column in a table contains sorting and filtering options.

Sorting a table
Sorting a table rearranges the rows based on the contents of a particular column. You may want
to sort a table to put names in alphabetical order. Or, maybe you want to sort your sales staff by
the total sales made.
To sort a table by a particular column, click the drop-down arrow in the column header and
choose one of the sort commands. The exact command varies, depending on the type of data in
the column. Sort A to Z and Sort Z to A are the options that appear when the columns contain
text. The options for columns that contain numeric data or True/False are Sort Smallest to
Largest and Sort Largest to Smallest. Columns that contain dates change the options into Sort
Oldest to Newest and Sort Newest to Oldest.
You can also select Sort by Color to sort the rows based on the background or text color of the
data. This option is relevant only if you’ve overridden the table style colors with custom colors, or
if you’ve used conditional formatting to apply colors based on the cell contents.

When a column is sorted, the drop-down control in the Header row displays a different
graphic to remind you that the table is sorted by that column. If you sort by several col-
umns, only the column most recently sorted displays the sort graphic.

You can sort on any number of columns. The trick is to sort the least significant column first and
then proceed until the most significant column is sorted last.
For example, in the real estate listing table, you may want the list to be sorted by agent. And
within each agent’s group, the rows should be sorted by area. And within each area, the rows
should be sorted by list price. For this type of sort, first sort by the List Price column, then sort by
the Area column, and then sort by the Agent column. Figure 9-7 shows the table sorted in this
manner.

14_475362-ch09.indd 246 4/14/10 10:09 PM


Chapter 9: Tables and Worksheet Databases 247

Figure 9-7: A table, after performing a three-column sort.

Another way of performing a multiple-column sort is to use the Sort dialog box. To display this
dialog box, choose Home➜Editing➜Sort & Filter➜Custom Sort. Or, right-click any cell in the
table and choose Sort➜Custom Sort from the shortcut menu.
In the Sort dialog box, use the drop-down lists to specify the first search specifications. Note that
the searching is opposite of what I described in the previous paragraph. In this example, you start
with Agent. Then, click the Add Level button to insert another set of search controls. In this new
set of controls, specify the sort specifications for the Area column. Then, add another level and
enter the specifications for the List Price column. Figure 9-8 shows the dialog box after entering
the specifications for the three-column sort. This technique produces exactly the same sort as
described in the previous paragraph.

Figure 9-8: Using the Sort dialog box to specify a three-column sort.

14_475362-ch09.indd 247 4/14/10 10:09 PM


248 Part II: Using Functions in Your Formulas

Filtering a table
Filtering a table refers to displaying only the rows that meet certain conditions. After applying a
filter, rows that don’t meet the conditions are hidden.

Excel provides two ways to filter a table. This section discusses standard filtering (for-
merly known as AutoFiltering), which is adequate for most filtering requirements. For
more complex filter criteria, you may need to use advanced filtering (discussed later in
this chapter).

Using the real estate table, assume that you’re only interested in the data for the N. County area.
Click the drop-down control in the Area Row header and remove the check mark from Select All,
which deselects everything. Then, place a check mark next to N. County and click OK. The table,
shown in Figure 9-9, is now filtered to display only the listings in the N. County area. Notice that
some row numbers are missing; these rows contain the filtered (hidden) data.
Also notice that the drop-down arrow in the Area column now shows a different graphic — an
icon that indicates the column is filtered.

Figure 9-9: This table is filtered to show only the information for N. County.

You can filter by multiple values — for example, filter the table to show only N. County and
Central.
You can filter a table using any number of columns. For example, you may want to see only the
N. County listings in which the Type is Single Family. Just repeat the operation using the Type
column. All tables then display only the rows in which the Area is N. County and the Type is
Single Family.
For additional filtering options, select Text Filters (or Number Filters, if the column contains val-
ues). The options are fairly self explanatory, and you have a great deal of flexibility in displaying
only the rows that you’re interested in.

14_475362-ch09.indd 248 4/14/10 10:09 PM


Chapter 9: Tables and Worksheet Databases 249

In addition, you can right-click a cell and use the Filter command on the shortcut menu. This
menu item leads to several additional filtering options. For example, you can filter the table to
show only rows that contain the same value as the active cell.

As you may expect, the Total row (if present) is updated to show the total for the visi-
ble rows only.

Some of the standard spreadsheet operations work differently with a filtered table. For example,
you might choose Home➜Cells➜Format➜Hide & Unhide➜Hide Rows to hide rows. If you then
copy a range that includes those hidden rows, all the data gets copied (even the hidden rows).
When you copy data in a filtered table, though, only the visible rows are copied. This filtering
makes it very easy to copy a subset of a larger table and paste it to another area of your work-
sheet. Keep in mind that the pasted data is not a table — it’s just a normal range.
Similarly, you can select and delete the visible rows in the table, and the rows hidden by filtering
will not be affected.
To remove filtering for a column, click the drop-down control in the row Header and select Clear
Filter. If you’ve filtered using multiple columns, it may be faster to remove all filters by choosing
Home➜Editing➜Sort & Filter➜Clear.

Working with the Total row


The Total row is an optional table element that contains formulas that summarize the information
in the columns. Normally, the Total row isn’t displayed. To display the Total row, choose Table
Tools➜Design➜Table Style Options➜Total Row. This command is a toggle that turns the Total
row on and off.
By default, the Total row displays the sum of the values in a column of numbers. In many cases, you’ll
want a different type of summary formula. When you select a cell in the Total row, a drop-down
arrow appears, and you can select from a number of other summary formulas (see Figure 9-10):

h None: No formula.
h Average: Displays the average of the numbers in the column.
h Count: Displays the number of entries in the column. (Blank cells are not counted.)
h Count Numbers: Displays the number of numeric values in the column. (Blank cells, text
cells, and error cells are not counted.)
h Max: Displays the maximum value in the column.
h Min: Displays the minimum value in the column.
h Sum: Displays the sum of the values in the column.
h StdDev: Displays the standard deviation of the values in the column. Standard deviation
is a statistical measure of how “spread out” the values are.

14_475362-ch09.indd 249 4/14/10 10:09 PM

Vous aimerez peut-être aussi