Handout Excel as database

advertisement
Intermediate Excel Topics: Using Excel as a Database
Getting started ........................................................................................................................... 1
Defining terms ........................................................................................................................ 1
Rules for constructing your list ................................................................................................ 1
Standard list layout ................................................................................................................. 2
Building a list .............................................................................................................................. 2
Setting up your list .................................................................................................................. 2
Entering data into your list ...................................................................................................... 2
Telling Excel that your list is really a list .................................................................................. 2
Printing your list ...................................................................................................................... 3
Using “Scaling” and “Fit to” options ......................................................................................... 3
Printing part of a list ................................................................................................................ 3
Freezing panes....................................................................................................................... 3
Viewing the list ....................................................................................................................... 3
Data entry .................................................................................................................................. 4
Creating a data entry form ...................................................................................................... 4
Adding new records using the data form................................................................................. 4
Searching records using the data form ................................................................................... 5
Using operators to search....................................................................................................... 5
Find and replace using the worksheet .................................................................................... 5
Edit records in the data form................................................................................................... 6
Deleting records using the data form ...................................................................................... 6
Deleting records using the worksheet ..................................................................................... 6
Using data validation .............................................................................................................. 6
Creating a dropdown list of allowable choices ........................................................................ 7
Sorting your list on one field ................................................................................................... 8
Sorting using multiple criteria.................................................................................................. 8
Filtering ...................................................................................................................................... 9
Using AutoFilter ...................................................................................................................... 9
Selecting multiple AutoFilters ................................................................................................10
Understanding special filter options .......................................................................................10
Creating a custom filter ..........................................................................................................10
Using an advanced filter ........................................................................................................11
Requirements for an advanced filter ......................................................................................11
Step 1: Creating a criteria range ...........................................................................................11
Step 2: Specifying your criteria .............................................................................................11
Step 3: Running the filter ......................................................................................................12
Extracting advanced filter results to another location .............................................................12
Data analysis ............................................................................................................................12
Creating subtotals .................................................................................................................12
Using Excel’s outlining tools ..................................................................................................13
Database functions ................................................................................................................14
Using DSUM to analyze your list ...........................................................................................14
Using DCOUNT .....................................................................................................................15
Creating a VLOOKUP............................................................................................................16
Using conditional formatting ..................................................................................................17
Getting started
Defining terms
Header row: the first row of a list. It contains labels for each specific piece of information that
is tracked in the list.
Field names: describe each piece of data stored in the list. Generally, the field name is the
label at the top of each column.
Data field: each cell containing a piece of data.
Record: a single row of data fields that comprises all of the information related to that particular
item or person.
Field names
Header row
Record
Data field
Rules for constructing your list
Do these things:
 Decide what data you want to compile before you start creating the list.
 Always break things down to the lowest common denominator.
 Label every column: Excel needs a column label (also known as a field name) to identify
and filter the data stored in your list.
 Put all your data into a single worksheet—your list can only exist on one worksheet, and
you can only have one list on each worksheet.
 Use descriptive names: avoid names that might be confused with cell addresses, such
as Q1, Q2, etc.
 Use text to name fields: numbers might be interpreted as part of a formula.
 Be consistent. Without consistency, your ability to sort and filter effectively is
undermined. For example, your list of company names, entered by a variety of people,
could include the following:
 Eliot Engineering
 Elliot Engineering
 Elliott Engineering
Excel sees those as three separate items, rather than misspellings of the same company
name. If you filter on Eliot Engineering, it will only return records using that spelling,
which could lead you to produce incomplete or incorrect information.
Don’t do these things:
 Include empty rows or columns: Excel sees empty columns or rows as indicating the
end of a list. Use formatting, if necessary, to make parts of the list stand out, rather than
spacing.
 Include blank columns on left: Again, it will just confuse Excel and lead to errors.
 Use duplicate field names: Excel is smart, but not smart enough to sort when there are
duplicate field names.
Using Excel as a Database
1

Don’t use the field name “Name.” Instead, break it down to First Name, Middle Initial,
Last Name.
Standard list layout
Horizontal field names: bold, uppercase, 12-point font
Body text: all caps or initial caps, 10-point font
Font style: Arial, Tahoma, Courier, Garamond
Building a list
Setting up your list
Click into cell A1. Enter the first field name.
Hit the Tab key, move to the next cell, and enter the next field name.
Repeat this process until all field names are entered.
Click and drag to select all of the field names. Click on the Bold button on the Formatting
toolbar.
Entering data into your list
Click in the first empty cell below the row of field names.
Enter the first piece of information. Use the Tab key to proceed across the row, entering as
much information as possible.
To move to the next row, press the Enter key on your keyboard or use the mouse to select the
first cell in the next row.
Telling Excel that your list is really a list
Once you have entered a few rows of data, it’s always a good idea to clarify with Excel that you
are building a list. By defining your data as a list, you activate some of Excel’s built-in features,
such as allowing the easy creation of a data entry form.
Select the first cell of the first row (cell A1).
Hold down the Shift key, and then click on the last cell in the last row of data.
All of the cells between should now be highlighted.
Use one of the following techniques to define this area as a list:
 Keyboard shortcut: Ctrl + L
 Menu command: Click on the Data menu, select List, and then select Create List.
With either approach, a dialogue box appears showing the range of cells selected.
Be sure to check the box for “My list has headers.”
Click on the OK button.
Using Excel as a Database
2
Your list now has a blue border around it, and AutoFilter list arrows appear beside each field
name, which allow you to filter quickly. The blank last row of the list is now defined as an insert
row where you can enter new data for the list.
AutoFilter list arrow
List border
Insert row
Printing your list
Printing an Excel list is the same process as with any regular worksheet. Unfortunately, it is
fraught with all of the same problems that plague the printing of a regular Excel worksheet—
columns that drop off unexpectedly, too many pages printing, etc. Always use the Print Preview
command to check your list before printing. Below are a couple of suggestions to help with
printing.
Using “Scaling” and “Fit to” options
If your list is just a little too big to fit on the desired number of pages, Excel’s “Fit to” command
can be quite useful.
Click on the File menu and select Page Setup.
In the “Scaling” area, click on the button beside “Fit to” and then enter in the number of pages.
Click on the Print Preview button to make sure your list is still legible.
Note: The “Fit to” command cancels out any manual page breaks you may have created.
Printing part of a list
Excel makes it easy to print only a subset of a list.
Highlight the data you want to print.
Click on the File menu, select Print Area, and then select Set Print Area.
A dotted line appears around the cells you selected.
Click on the File menu and select Print, or use the keyboard shortcut: Ctrl + P.
Note: this handy feature can trip you up if you forget that you have used it. To make it possible
to print the entire worksheet, click on the File menu, select Print Area, and then select Clear
Print Area.
Freezing panes
Freezing panes is similar to splitting the worksheet, but it does not allow you to scroll through
each part of the worksheet. Freezing is most useful when you want to keep header information
visible at all times, while you enter data or perform calculations in another part of the worksheet.
Click on the row number just below the row you want to freeze.
Click on the Window menu and select Freeze Panes.
To turn off the freeze panes feature: Click on the Window menu and select Unfreeze Panes.
Viewing the list
Depending on the number of fields in your list, it may be a good idea to
create a custom view of your list.
Zoom box
Using Excel as a Database
3
First, select the entire list: hold down the Ctrl + * keys (use the * from the 10-key pad, not the *
from holding down Shift + 8).
Click on the dropdown arrow beside the Zoom box and choose Selection from the bottom of
the list.
This action adjusts the screen to fit all of the columns into view, which will either shrink or
expand your display somewhat.
Click on the View menu and select Custom View; the Custom Views window opens.
Click on the Add button.
Enter a name for your new view and then click on OK.
To return to this view at a later date, click on the View menu, select Custom Views, and then
select the appropriate view from the list.
Data entry
Creating a data entry form
It is easy to enter data into your list by typing directly into the blank rows, but for lists that
contain a large number of fields, it can be tedious and time-consuming to scroll horizontally to
keep up with the spreadsheet. Instead, use a data form, which presents all of the fields in a
single dialogue box.
Click somewhere in your list so that a cell is selected.
Click on the Data menu and then select Form.
A new form appears containing all of the fields in your list and a set of navigational buttons on
the right-hand side.
Adding new records using the data form
Click on the New button.
Using Excel as a Database
4
A blank form appears. Enter the appropriate information in the first text box, and then use the
Tab key to move to the next field.
To complete the record and start another, hit the Enter key on your keyboard or click on the
New button on the data form.
Searching records using the data form
In addition to simplifying data entry, the data form can make it much easier to search for specific
records within a large list.
If the form is not showing, click on the Data menu and select Form.
Click on the Criteria button; this clears whatever data is showing in the form.
Enter a term or terms in the appropriate field.
Hit the Enter key or use the Find Prev or Find Next buttons to flip through all of the records
found.
When you reach the last record that matches your criteria, Excel beeps if you try to continue
your search in that direction.
To perform a different search, click on the Criteria button again. If necessary, be sure to clear
any existing criteria.
To return to data entry mode with your form, click on the Form button.
Using operators to search
Operator
?
*
>
<
What it does
Stands for any single character
Stands for any group of
characters
Finds records greater than the
term used
Finds records less than the term
used
Sample
Pauls?n
Jan*
Search result(s)
Paulson, Paulsen
Jan, Janet, Janie, Janice
>90000
All customers whose ZIP is
greater than 90000
Finds all customers whose last
name comes before S in the
alphabet
<s
Find and replace using the worksheet
If you need to make widespread changes to your data, it is more efficient to do so in the
worksheet itself, using Excel’s Find and Replace dialogue.
Click on the Edit menu and select Replace or use the keyboard shortcut: Ctrl + H
Once you have entered the appropriate data in the “Find what” textbox and the “Replace with”
textbox, you much choose how to proceed: do you need to look at each spot where the data is
found? If so, use the Find Next button, and choose to replace or not on a case-by-case basis.
If you are certain that a mass find-and-replace operation will not affect the integrity of your list,
you can click on the Replace All button to complete the operation.
You can click on the Options button to fine tune your search and replace operations.
In the expanded window you can choose among the follow:
 A direction for the search (within the sheet or workbook, by rows or columns)
Using Excel as a Database
5




To match the case of text
To match the entire contents of the cell
To look only for formulas, values, or comments
To search for specific formatting
Edit records in the data form
If you have minor editing tasks, you can use the data form to find and update records.
If the form is not showing, click on the Data menu and select Form.
Search using the appropriate criteria.
Make whatever changes are necessary.
To process the changes, click on the New button to start a new record, or click on Find Next or
Find Prev if you are using a search criteria.
Deleting records using the data form
Once you’ve learned how to search using the data form, you can extend the form’s utility by
using it to delete obsolete records.
If the form is not showing, click on the Data menu and select Form.
Search using the appropriate criteria.
When a record appears that is now obsolete, click on the Delete button on the right-hand side of
the form.
Continue finding and deleting as needed.
Note: when you delete a record using the data form, you cannot undo your deletion.
Deleting records using the worksheet
If you need to delete a large number of records, it is probably more time-efficient to do so in the
worksheet.
Open the list and sort it in order to group all of the obsolete records together.
If the records are contiguous:
Click on the row number for the first record to be deleted.
Hold down the Shift key and select the last record to be deleted; all of the records in between
are also selected.
Right-click and select Delete from the shortcut menu.
If the records are not contiguous:
Click on the row number for the first record to be deleted.
Hold down the Ctrl key and click on all of the remaining records that are to be deleted.
Right-click and select Delete from the shortcut menu.
Note: records that are deleted from the worksheet in this manner can be restored; click on the
Undo button on the Standard toolbar or use the keyboard shortcut, Ctrl + Z.
Using data validation
Data validation allows you to exert some quality-control measures over the data that is entered
into your list; for example, you can specify an acceptable range of dates, or develop a list of
region names or keywords to be used in a specific field.
Select the column or row to which you want to apply data validation.
Click on the Data menu and select Validation.
Using Excel as a Database
6
When the Data Validation window appears, click on the Settings tab, if necessary.
In the Allow dropdown list, choose what type of data that column or row can include (date, time,
any value, list, etc.).
In the Data dropdown list, choose the appropriate descriptor (greater than, between, etc.). Note
that the Data menu is not available if you choose List from the Allow dropdown menu.
The labels applied to the boxes where you enter your criteria will vary depending on what sort of
data you are validating. In the example shown here, they are start and end date. Enter the
appropriate criteria into the box or boxes.
Click on the Input Message tab to create a popup balloon that informs anyone entering data
about the validation rules governing a particular column.
Enter a title into the “Title” textbox.
In the “Input message” textbox, enter the text explaining what sort of data this column accepts.
If you create an input message, it will look something like this:
Sample input
message
Click on the Error Alert tab to create a message that pops up explaining any data entry errors
that might occur.
Choose an icon from the Style dropdown list.
Enter a title into the “Title” textbox.
In the “Error message” textbox, enter the text that explains what sort of data this column
accepts.
If you create an error message, it will look something like this:
When you have entered all of the criteria and created whatever informational and error
messages you want, click on the OK button.
Creating a dropdown list of allowable choices
One of the best ways to control for consistency in your data is to limit the options of what is
allowed within a cell. This becomes particularly important when different people keying data
could enter variants of a term, such as web or website or WWW.
Click on the column letter to select the column.
Click on the Data menu and select Validation.
Using Excel as a Database
7
In the Data Validation window, click on the Settings tab, if necessary.
In the Allow dropdown menu, select List.
In the Source textbox, type in all of the available options, or select the cells containing the list of
available options.
Add input and error messages, if desired.
Click on the OK button.
Click into the first blank cell for the column; a dropdown arrow appears, and when you click on it
you will see the list of items you created.
Sample dropdown list
Sorting your list on one field
Before doing any sort of sorting on a list, I strongly recommend making a backup copy of your
data, so that if something goes wrong you can return to your original data without any problems.
The easiest way to sort data in Excel is to use the Sort Ascending
Sort Ascending and
and Sort Descending buttons.
Sort Descending
Click on the column letter of the column you need to sort, and then
click on the appropriate sort button.
If you haven’t already defined your data as a list, you might get a warning window like the one
shown below:
If you want the data in other columns to be sorted along with the selected column (which you
probably do to preserve the integrity of the data), choose “Expand the selection” and then click
on the Sort button.
Sorting using multiple criteria
For more complex sorts, you will need to use the Sort tool.
Select within the list area.
Click on the Data menu and select Sort.
Using Excel as a Database
8
In the Sort window, double-check to make sure that Excel realizes that your list has a header
row in the “My data range has” area (that option should be grayed out).
Then, click on the dropdown arrow under the first Sort by box and select the first criteria you
want to use when sorting.
Repeat the process two more times, if need be. Note that you can sort both Ascending and
Descending by clicking on the radio buttons on each level of sorting.
Click on the OK button when you have specified the correct criteria.
Note: if the sort does not do what you wanted, remember that you can use Excel’s undo
feature to return your data to its prior, unsorted state:
 Ctrl + Z
 The Undo button
 Click on the Edit menu and select Undo
Filtering
In Excel, there are two types of filters you can use to view the data in your list:
AutoFilter: an automatic selection filter, which can be customized
Advanced filters: allows you to specify more complex criteria
Using AutoFilter
To apply an AutoFilter to a list, select a cell in the list, click on the Data menu, select Filter, and
then select AutoFilter.
AutoFilter
buttons
AutoFilter
dropdown menu
Excel displays dropdown arrow buttons on each column; when you click on an arrow it displays
a list of all items in that category. Click on one of the items on the list and Excel will filter the list
to show only those records that match the selected item.
Note: you can only select one item within a field.
Using Excel as a Database
9
Selecting multiple AutoFilters
It is possible to select more than one AutoFilter button. This creates what Excel calls a
“combined filter.” Simply click on the first dropdown button, select an item from its list, and then
repeat the process until you have filtered on all necessary items. The example below shows a
list filtered by Household Type and State.
Note that once you have selected an AutoFilter button, it is shaded blue to indicate that it is in
use.
Pay attention to the order in which you apply filters, as that can give you unexpected results if
you choose a more-restrictive filter before the less-restrictive options.
Understanding special filter options
Note that several options appear at the top and bottom of the AutoFilter dropdown list.
(All): display all records in that category. Use this option to redisplay the entire list once you
have used the field for a filter.
(Top 10…): only available in columns containing numbers or dates. Choosing this option
brings up the Top 10 AutoFilter window, where you can specify records at the top or bottom of
the list numerically. You aren’t limited to 10 records but instead can specify the number you
wish to see.
(Custom…): opens the Custom AutoFilter window—see the “Creating a custom filter“ section
below for more information on that option.
(Blanks): display records containing blanks in that column. This option only appears if the
column has empty cells.
(NonBlanks): display all records containing any data in that column. This option only appears
if the column has empty cells.
Creating a custom filter
A custom AutoFilter allows you to create a more complex filter within the AutoFilter framework.
Click on the dropdown arrow for the appropriate field and select (Custom…).
Specify the criteria to use by selecting a condition from the first dropdown menu and specifying
its value in the textbox on the right-hand side of the window.
If you want to add a second condition, choose between And/Or for the joining syntax and then
fill out the second set of criteria boxes.
Note: Choosing And means that the data has to meet both sets of criteria.
Choosing Or means that the data has to meet either of the criteria you specify.
When you have specified your criteria, click on the OK button.
Using Excel as a Database
10
Note: to return the list to its original state, click on the dropdown arrow for that field and select
(All).
Using an advanced filter
Excel’s advanced filter was created to handle criteria that can’t be specified by using the custom
filter. For example, if you wanted to filter for clients in more than two states, you must use an
advanced filter, because the custom filter limits you to specifying two criteria.
The advanced filter also allows you to set up criteria using the OR joining syntax across fields.
For example, you could filter for clients in the state of North Carolina OR clients whose
purchases to date total more than $2,000.
The other advantage to the advanced filter is that it allows you to extract the filtered information
to a separate spot on the same worksheet, so that you can see all of the original data and then
the filtered data as well.
Requirements for an advanced filter
Creating an advanced filter is a three-step process:
1. Creating a criteria range
2. Specifying your criteria
3. Running the filter
Step 1: Creating a criteria range
A criteria range is a cell range containing one row of field names and at least one additional row
that contains the criteria you want to match.
Highlight the first six rows of your list by clicking on the first row number and dragging down
across the row numbers.
Note: I like to add six additional rows so that I have plenty of room for multiple criteria and
some blank space to make it clear to me what is going on with this worksheet. You can choose
to add more or fewer blank rows, but there must be at least one blank row between your criteria
range and the list to keep Excel from getting confused.
Right-click on the row numbers and select Insert from the shortcut menu.
Six blank rows should appear directly above your field names.
Select the row number that contains your list of field names.
Right-click on the row number and select Copy from the shortcut menu.
Right-click on row number 2 and select Paste. Your field names should now be copied into the
blank range of cells that you created.
Step 2: Specifying your criteria
Underneath the appropriate field name, enter your first criteria. See the samples below:
<5/1/2002: filters for dates before 5/1/2002
CA: shows only those records with the state of CA
>40000: shows ZIP codes greater than 40000
Using Excel as a Database
11
Notes on specifying criteria: if you put two criteria on the same line, you are using the AND
joining syntax. Often this is not a good idea!
Criteria on separate lines are using the OR joining syntax.
Step 3: Running the filter
Click any cell in the list.
Click on the Data menu, select Filter, and then select Advanced Filter.
In the Advanced Filter window, the list range addresses should already appear, but you must
specify where the criteria range is located.
Click on the first cell containing the criteria range field name; click and drag to select all of the
field names and the row(s) containing criteria.
Click on the OK window to run the advanced filter.
The filtered list replaces your original dataset.
Note: to return to the original list, click on the Data menu, select Filter, and then select Show
All.
Extracting advanced filter results to another location
One additional advantage to the advanced filter is that it gives you the option to place your
results in a different location, rather than replacing the original list.
In the Advanced Filter window, select “Copy to another location.”
The Copy to textbox becomes available; you can type in the cell address where you’d like the
results to start pasting, or click on the cell itself.
Click on the OK button; the filter results will appear in the location you specified.
Data analysis
Creating subtotals
You can only create subtotals in a data range, not in a list. To convert your list to a range:
Click on the Data menu, select List, and then select Convert to Range.
A warning window appears asking if you want to convert the list to a range; click on the Yes
button.
The blue outline around your data disappears, along with the Insert row at the bottom and the
AutoFilter arrows on the field names.
Sort the list as necessary to arrange your data properly. For example, if you want to view
subtotals by state, sort by state.
Select any cell within your list.
Click on the Data menu and select Subtotals to bring up the Subtotals window.
Using Excel as a Database
12
In the “At each change in” dropdown list, select the appropriate field
name. For our example, select the field name State.
In the “Use function” dropdown list, choose the appropriate function.
For our example, select Sum.
In the “Add subtotal to” dropdown, select the field name containing the
data to be subtotaled.
If you’re performing a new subtotal function and want to replace the
existing subtotals in your list, click on the checkbox beside “Replace
current subtotals.” If you leave that box unchecked, Excel adds
additional subtotals to those you have already created.
If your list is sufficiently large, you might want to check the box beside “Page break between
groups.” This could save you a step if you will need to print the list later.
If you want to see both subtotals and a grand total at the bottom of the list, check the box beside
“Summary below data.” Otherwise, the subtotals and grand total appear the first entry in each
group and the grand total at the top of the column just below the row of field names. Consider
the overall size of your list before making this decision—if it’s important to see the final result
Subtotal
Grand total appearing
at bottom of list
Outlining tools
without having to flip through several pages of data, leave this box unchecked.
Grand total appearing
at top of list
Outlining tools
Subtotal
When you’ve made all necessary choices, click on the OK button.
Using Excel’s outlining tools
When the results of a subtotaled list appear, several useful outlining tools appear along the lefthand side of the list. Once your subtotals are in place, these buttons allow you to expand or roll
up data quickly.
Row level symbols: a set of numbers indicating the number of levels represented by the data
in your list. To roll up or expand all the data to that level, click on the number.
Hide Details button: click on the Hide Details button for a specific group of data to roll it up so
that it is not displayed.
Using Excel as a Database
13
Show Details button: click on the Show Details button to expand the list so you can view all
the details of that group.
This screenshot shows the rolled-up CT total, and an expanded MA total (with specific details
included).
Row level symbols
Hide Details button
Show Details button
This screenshot shows all of the states rolled up, so you can quickly scan the totals.
Database functions
Excel includes a variety of functions specifically designed to extended the functionality of your
list, including the following:
DSUM: similar to sum, except that it allows you to create a sum based on criteria
DMAX: looks up the highest value in a list
DMIN: looks up the lowest value in a list
DPRODUCT: returns the product of multiplying values that meet a certain set of criteria
DAVERAGE: returns the average of the values that meet a set of criteria
DCOUNT: counts the number of cells that contain values that meet a set of criteria
Using DSUM to analyze your list
The DSUM function allows you to perform criteria-based sum operations on your list. For
example, you could total the number of citizens who found their way to the Albemarle County
website based on their source (link on another site, County advertising,
newspaper story, etc.).
Before creating a DSUM function, you must convert your
data list to a data range (a collection of named cells).
Name Box
Using Excel as a Database
14
Click and drag to highlight the entire list, including the field names (a good keyboard shortcut:
Ctrl and the * key on the numeric keypad).
Click into the Name Box and enter a name for your range; using something simple like “List” is
fine.
Note: range names cannot include a space. Use an underline if necessary: Customer_List.
Now you’re ready to apply the DSUM function.
The first step is to set up the appropriate labels on your worksheet. The example of analyzing
the traffic on the Albemarle County website is used below:
This label is just text to help the
viewer understand the information
being presented.
These two labels are
purely informational to
make the spreadsheet
easier to understand.
The “Source” and “website” cells are
what make the function work. The
function pulls all “time on site”
records that also contain the source
“website” and sums that group to
arrive at its result.
Once your data labels and source information are correctly set up, click on the blank cell to the
right of “Time on site” and then click on the Function button. This will
Function button
insert the results of the DSUM function in the appropriate spot.
In the Insert Function window, type DSUM in the “Search for a function” textbox and then hit the
Enter key or click on the Go button.
Click on DSUM in the “Select a function” results area, and then click on the OK button.
In the Function Arguments window, fill out the arguments textboxes as described below,
Name of range you assigned to
your list (hit F3 to see a list of all
ranges in your worksheet)
Label of the column the function
searches to retrieve the numbers
it is summing up
Range that contains the list
criteria
remembering to substitute the cell references that are appropriate to your worksheet’s structure.
When you have entered all of the arguments, click on the OK button.
Once you see the result for the first source you entered, enter another source and see if the
“Time on site” data changes.
Using DCOUNT
The DCOUNT function will count a list based on criteria that you specify. Building on the
example used above, you can present information about how many chose a certain source.
As with the DSUM function, the first step is to give your list a range name, if it doesn’t already
have one.
Click and drag to highlight the entire list, including the field names (a good keyboard shortcut:
Ctrl and the * key on the numeric keypad).
Using Excel as a Database
Name Box
15
Click into the Name Box and enter a name for your range; using something simple like “List” is
fine.
Note: range names cannot include a space. Use an underline if necessary: Customer_List.
Now you’re ready to apply the DCOUNT function.
Click into the cell just to the right of the “Count by source” label and then click on the Function
button. This will insert the results of the DSUM function in the appropriate spot.
In the Insert Function window, type DCOUNT in the “Search for a function” textbox and then hit
the Enter key or click on the Go button.
Click on DCOUNT in the “Select a function” results area, and then click on the OK button.
In the Function Arguments window, fill out the arguments textboxes as described below,
Name of range you assigned to your
list (hit F3 to see a list of all ranges in
your worksheet)
Label of the column the function
searches to count the number of
records that match the criteria.
Because this is a simple count of
matching records, you can select any
number field in the list.
Range that contains the list criteria
remembering to substitute the cell references that are appropriate to your worksheet’s structure.
When you have entered all of the arguments, click on the OK button.
Once you see the result for the first source you entered, enter another source and see if the
“Count by source” data changes.
Creating a VLOOKUP
Excel contains a function named VLOOKUP that performs automatic searches against your
data list for a specified term. This function is particularly useful for a large list, as it can save
you time and eyestrain. For example, you might want to be able to enter a customer number
and retrieve a certain piece of information. Rather than finding the customer number and then
scrolling across the screen to locate the data you need, a VLOOKUP allows you to enter the
customer number in a cell and then displays the desired information wherever you specify.
Before creating a VLOOKUP function, you must convert your data list to a data range (a
collection of named cells).
Click and drag to highlight the entire list, including the field names (a good
keyboard shortcut: Ctrl and the * key on the numeric keypad).
Click into the Name Box and enter a name for your range; using
something simple like “List” is fine. Note: range
Name Box
names cannot include a space, but can include an
underline: Customer_List.
Now you’re ready to apply the VLOOKUP function.
To make your VLOOKUP easier to build (and to understand later!), start by labeling the cells
where you will be entering information. See the sample below for a guide:
Using Excel as a Database
16
Note: all of the following directions use this sample and its appropriate references. Please
remember as you build your VLOOKUP that your arguments will differ based on how your
worksheet is set up.
Click into the cell where you want the VLOOKUP results to appear.
Click on the Insert Function button.
Function button
In the Insert Function window, type VLOOKUP in the “Search for a
function” textbox and then hit the Enter key or click on the Go button.
Click on VLOOKUP in the “Select a function” results area, and then click on the OK button.
In the Function Arguments window, fill out the arguments textboxes as described below,
remembering to substitute the cell references that are appropriate to your worksheet’s structure.
When you have entered all of the arguments, click on the OK button. Nothing will happen yet,
because you haven’t entered a value in the Customer Number cell.
Cell where you will enter data to search for
Name of range you assigned to your list
(hit F3 to see a list of all ranges in your
worksheet)
Number of the column where Excel will
search for the data you specify
Specify whether you want an exact match
(False) or the closest value (True)
To test the function, enter one of the customer numbers in cell S2 (or wherever you have
located it) and then hit the Enter or Tab key. The household type data for that record should
appear.
Using conditional formatting
Conditional formatting allows you to set formats that appear on your worksheet if data meet a
certain criteria. For example, you can create a conditional format that highlights those cells in a
list that match an entry in a different cell, or highlight data that exceeds a specified range.
Using Excel as a Database
17
Conditional formats are most powerful when combined with other formulas or functions. For
example, if you were creating a DSUM or DCOUNT, as in the example above, you could apply
conditional formatting to highlight the selected source.
Select the cells to which you want to apply the conditional format. In this example, it is the cells
for the Source field.
Click on the Format menu and select Conditional Formatting.
In the Conditional Formatting window, fill out the criteria as described below.
Click on the dropdown
here to choose the
appropriate condition.
Select the cell
containing the
criteria to which
the conditional
formatting is
linked.
Click on the Format button
to specify the formatting to
be used.
In the Format Cells window, you can choose to apply special formatting to the font, border, or
pattern. Use the Patterns tab if you want to change the fill color to draw attention to a cell.
Using Excel as a Database
18
Download