Sie sind auf Seite 1von 5

9

Tables and Worksheet


Databases
In This Chapter
● Using Excel’s table feature
● Basic information about using tables and worksheet databases
● Filtering data using simple criteria
● Using advanced filtering to filter data by specifying more complex criteria
● Understanding how to create a criteria range for use with advanced filtering or database
functions
● Using the SUBTOTAL function to summarize data in a table
A table is a rectangular range of data that usually has a row of text headings to describe the con-
tents of each column. Excel 2007 introduced a new twist by letting you designate a range as an
“official” table, which makes common tasks much easier. More importantly, this table feature may
help eliminate some common errors.
This chapter discusses Excel tables and also covers what I refer to as worksheet databases, which
are essentially tables of data that have not been converted to an official table.

Tables and Terminology


It seems that Microsoft can’t quite make up its mind when it comes to naming some of Excel’s
features. Excel 2003 introduced a feature called lists, which is a way of working with what is
often called a worksheet database. In Excel 2007, the list features evolved into a much more use-
ful feature called tables (and that feature was enhanced a bit in Excel 2010). To confuse the issue
even more, Excel also has a feature called data tables, which has nothing at all to do with the
table feature. And don’t forget about pivot tables — which are not tables, but can be created
from a table.

235

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


236 Part II: Using Functions in Your Formulas

In this section, I define the terms that I use throughout this chapter.

h Worksheet database: An organized collection of information contained in a rectangular


range of cells. More specifically, a worksheet database consists of a row of headers
(descriptive text), followed by additional rows of data comprising values or text. I use the
term database loosely. An Excel worksheet database is more like a single table in a stan-
dard database. Unlike a conventional database, Excel does not allow you to set up rela-
tionships between tables.
h Table: A worksheet database that has been converted to a special range by using the
Insert➜Tables➜Table command. Converting a worksheet database into an official table
offers several advantages (and a few disadvantages), as I explain in this chapter.

A worksheet database example


Figure 9-1 shows a small worksheet database that contains employee information. It consists of 1
Header row, 7 columns, and 20 rows of data. Notice that the data consists of several different
types: text, numerical values, dates, and logical values. Column E contains a formula that calcu-
lates the monthly salary from the value in column D.

Figure 9-1: A typical worksheet database.

In database terminology, the columns in a worksheet database are fields, and the rows are
records. Using this terminology, the range shown in the figure has seven fields (Name, Location,
Sex, Salary, Monthly Salary, Date Hired, and Exempt) and 20 records.
The size of a database that you develop in Excel is limited by the size of a single worksheet. In
theory, a worksheet database can have more than 16,000 fields and can consist of more than one
million records. In practice, you cannot create a database of this size because it requires an enor-
mous amount of memory, and will cause even a state-of-the-art computer to slow to a crawl.

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


Chapter 9: Tables and Worksheet Databases 237

A table example
Figure 9-2 shows the employee worksheet database after I converted it to a table, using
Insert➜Tables➜Table.

Figure 9-2: A worksheet database, converted to a table.

What’s the difference between a worksheet database and a table?

h Activating any cell in the table gives you access to a new Table Tools context tab on the
Ribbon.
h The cells contain background color and text color formatting, applied automatically by
Excel. This formatting is optional.
h Each column header contains a button that, when clicked, displays a drop-down list with
sorting and filtering options.
h If you scroll the worksheet down so that the Header row disappears, the table headers
replace the column letters in the worksheet header. In other words, you don’t need to
“freeze” the top row to keep the column labels visible.
h Tables support calculated columns. A single formula entered in a column is propagated
automatically to all cells in the column.
h You can easily add a summary row at the bottom that summarizes the columns.
h Tables support structured references. Rather than using cell references, formulas can use
table names and column headers.
h When you move your mouse pointer to the lower-right corner of the lower-right cell, you
can click and drag to extend the table’s size, either horizontally (add more columns) or
vertically (add more rows).
h Excel is able to remove duplicate rows automatically.
h Selecting rows and columns within the table is simplified.

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


238 Part II: Using Functions in Your Formulas

Uses for worksheet databases and tables


People use worksheet databases (or tables) for a wide variety of purposes. For some users, a
worksheet database simply keeps track of information (for example, customer information); oth-
ers use a database to store data that ultimately appears in a summary report. Common database
operations include

h Entering data into the database


h Filtering the database to display only the rows that meet certain criteria
h Sorting the database
h Inserting formulas to calculate subtotals
h Creating formulas to calculate results on the data, filtered by certain criteria
h Creating a summary table of the data in the table (often done by using a pivot table)

When creating a worksheet database or table, it helps to plan the organization of your information.
See the “Designing a worksheet database or table” sidebar for guidelines to help you create tables.
Don’t worry if you later discover that your worksheet database or table needs one or more additional
columns. Excel is very flexible, and adding new columns is easy.

Designing a worksheet database or table


Although Excel is quite accommodating with regard to the information that is stored in a work-
sheet database, planning the organization of your information is important and makes the data
easier to work with. Remember the following guidelines when you create a worksheet database
or table:
● Insert descriptive labels (one for each column) in the first row (the Header row). If you
use lengthy labels, consider using the Wrap Text format so that you don’t have to widen
the columns to read the labels.
● Make sure that each column contains only one type of information. For example, don’t
mix dates and text in a single column.
● Consider using formulas that perform calculations on other fields in the same record. If
you use formulas that refer to cells outside the database, make these absolute references;
otherwise, you get unexpected results when you sort the table.
● Don’t leave any empty rows within the worksheet database. For normal worksheet data-
base operations, Excel determines the database boundaries automatically, and an empty
row signals the end of the data. If you’re working with a table, empty rows are allowed
because Excel keeps track of the table dimensions.
● Freeze the first row. Select the cell in the first column and first row of your table and then
choose View➜Freeze Panes➜Freeze Top Row to make sure that you can see the headings
when you scroll the table. This action is not necessary with a table because table headers
replace the column letters when you scroll down.

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


Chapter 9: Tables and Worksheet Databases 239

Working with Tables


It may take you a while to get use to working with tables, but you’ll soon discover that a table
offers many advantages over a standard worksheet database.
A major advantage of using a table is the ease with which you can format the table as well as
change the formatting. See the “Changing the look of a table” section, later in this chapter.
If you normally use a lot of named ranges in your formulas, you may find the table syntax to be a
welcome alternative to creating names for each column and the table as a whole — not to men-
tion the advantage of having named ranges that adjust automatically as the table changes.
A similar advantage is apparent when working with charts. If you create a chart from data in a
table, the chart series expands automatically after you add new data. If the chart data isn’t in a
table, you need to edit the chart series definitions manually (or resort to a few tricks) when new
data is added.
If your company happens to use Microsoft’s SharePoint service, you’ll see yet another advantage.
You can easily publish a table to your SharePoint server. To do so, choose Table Tools Design➜
External Table Data➜Export➜Export Table to SharePoint List. This command displays a dialog
box in which you type the address of your server and provide additional information necessary to
publish your designated table.
Tables, however, do have a few limitations compared to a worksheet database. (See the “Table
limitations” sidebar.)

Table limitations
Although an Excel table offers several advantages over a normal worksheet database, the Excel
designers did impose some restrictions and limitations on tables. Among them are that
● If a worksheet contains a table, you cannot create or use custom views (View➜Workbook
Views➜Custom Views).
● A table cannot contain multicell array formulas.
● You cannot insert automatic subtotals (Data➜Outline➜Subtotal).
● You cannot share a workbook that contains a table (Review➜Changes➜Protect and Share
Workbook).
● You cannot track changes in a workbook that contains a table (Review➜Changes➜Track
Changes).
● You cannot use the Home➜Alignment➜Merge & Center command cells in a table (which
makes sense because doing so would break up the rows or columns).
If you encounter any of these limitations, just convert the table back to a worksheet database by
using Table Tools➜Design➜Tools➜Convert To Range.

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

Das könnte Ihnen auch gefallen