Microsoft Excel Database Functions Tutorial

81 downloads 234 Views 3MB Size Report
Aston Business School Student Guide - Excel version 5.0 Database Functions ... This document is an introduction to the database functions contained within the ...
Aston Business School Student Guide - Excel version 5.0 Database Functions

Microsoft Excel v5.0 Database Functions

Student Guide

Simon Dupernex Aston Business School

Version 1.0

1

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

Preface This document is an introduction to the database functions contained within the spreadsheet program Excel 5. It tells you how to construct your own database from scratch. It is specifically tailored for students at Aston University but will be of use to anyone who has a copy of Excel version 5.0 for Windows. It assumes that you already know how to work with Windows on a PC.

Copyright  Simon Dupernex 1996. Permission is granted for any individual or institution to use, copy or redistribute this document in whole or in part, so long as it is not sold for profit and provided that the above copyright notice and this permission notice appears in all copies. Where any part of this document is included in another document due acknowledgement is required of the author and Aston Business School, Aston University, Birmingham B4 7ET. Although every care has been taken with the production of this training manual to ensure that its contents are correct, neither the author nor Aston University accept any responsibility in any way for the accuracy of the information given in the manual, or for any consequences suffered by any party who uses or relies on the information given in the manual.

Version 1.0

2

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

CONTENTS

Version 1.0

1

INTRODUCTION

4

3

GETTING STARTED AND ENTERING DATA

5

4

DATA FORMS

6

5

SORTING YOUR DATABASE

8

6

FILTERING A LIST USING AUTO FILTER

10

7

FILTERING A LIST USING ADVANCED FILTER

12

8

SUMMARY

16

3

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

1

INTRODUCTION.

Excel has available a simple database function called a list. A list is a way of storing data on a worksheet where a series of labelled rows contain similar data. An example of a list could be a set of results from a series of questionnaires, or the university telephone directory. An Excel list contains certain common features: ∗ Cells in the same column contain like data. ∗ The first row of the list contains the column labels. ∗ Rows in a list contain similar sets of data. So a list is a simple database where rows are records and columns are fields. Excel provides a powerful set of commands to make it easy to manage a list or a database. You can use a Data Form to see, change, add, and delete records from a list, or to find specific records based on criteria you specify. You can Sort the data to arrange rows in a list according to the contents of selected columns. You select the data and the sort order you want, or you can create and use a custom sort order. You can Filter the data to find and work with a subset of the data in your list. A filtered list displays only the rows that contain a certain value or rows that meet a set of criteria, while temporarily hiding the other rows. When you create a list, bear in mind the following guidelines: ∗ Avoid having more than one list on a worksheet. ∗ Leave at least one blank column and one blank row between your list and other data on the worksheet. ∗ Create column labels in the fist row of your list. ∗ Design your list so that all the rows have similar items in the same column. ∗ Don’t insert extra spaces at the beginning of a cell; this will affect sorting and searching.

Version 1.0

4

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

3

GETTING STARTED AND ENTERING DATA.

Turn on the PC and start Windows. After a short while the Microsoft Windows screen is displayed. Start the Excel spreadsheet program by double-clicking the Excel icon. Start with a clear worksheet by selecting the New option from the File menu. Your worksheet should look like:

Exercise. • Enter the following fictitious personnel data. Note that cells A1 through F1 inclusive are the column labels and that cells A2 through F9 inclusive contain the relevant data.

• Now save your spreadsheet on your floppy disk using Save As from the File menu.

Version 1.0

5

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

4

DATA FORMS.

Once a list has been created, you can add, find, edit, and delete records using a Data Form. The Form command on the Data menu displays a data form, which is a dialog box that you can use to see, change, add, and delete records from a list, or to find specific records based on criteria you specify. The column labels of your list become the field names in the data form. Exercise. Select any cell within your database (e.g. cell B3) and choose the Form command from the Data menu. The Data Form dialogue box will be displayed, containing the details of the first record in the list. Your screen should look like the one below. Practice scrolling through the records in your list.

To move around on the data form, press the TAB key to move ahead one field at a time, and then through the command buttons. Press SHIFT+TAB to move back one field or button at a time. The scroll bar enables you to scroll through the records in your list and shows the approximate position of the displayed record in the list. Move forward and back through the list by using the scroll box and the up and down scroll arrows on the scroll bar. The New button clears the fields in the Data Form dialog box. The Delete button deletes the displayed record; the other records shift up in the list. The Restore button restores edited fields in the displayed record, removing your changes. The Find Prev button displays the previous record in the list. The Find Next button displays the next record in the list. The Close button closes the data form.

Version 1.0

6

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

Entering a record onto the database. Exercise. • Choose the New button, and fill in the fields for employee 108, Grahan Smith. Remember to Tab between the fields. When you finish filling in the details, press Enter to add the record to the end of the list.

When you have successfully added the details, close the Data Form dialogue box by choosing the Close button.

Version 1.0

7

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

5

SORTING YOUR DATABASE.

Use the Sort command to arrange rows in a list according to the contents of particular columns. You can choose to sort in ascending or descending sort order. Exercise. • Select any cell within your database (e.g. cell A1) and choose the Sort command from the Data menu. Excel automatically selects every cell in your database, and then displays the Sort dialogue box. • To sort the list by Name: Select the Surname column in the Sort By box and the Ascending option button, then select the Forename column in the Then By box and the Ascending option button. Your screen should look like this:

• Select the OK button to sort the data.

Version 1.0

8

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

• Your sorted data should look like this:

Now practice sorting the database in different sequences. • When you have finished, restore the database back into Number sequence. Excel uses the following order for ascending sorts: Numbers Text, and text that includes numbers (postal codes, part numbers, etc.) Logical values (FALSE then TRUE) Error values Blanks A descending sort reverses the above order, except for blank cells, which are always sorted last. If the sort result is not what you expected, look at the type of data you are sorting. You can undo the results of a sort by immediately choosing the Undo Sort command from the Edit menu. For best results, make sure all of the cells in a column contain the same type of data.

Version 1.0

9

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

6

FILTERING A LIST USING AUTO FILTER.

Filtering a list enables you to find and work with a subset of the data in your list. Filtering displays only the rows that contain a certain value or that meet a set of criteria, while hiding the other rows. Exercise. • Select any cell within your database (e.g. cell D1) and choose the AutoFilter command from the Filter submenu from the Data menu. The AutoFilter command applies drop-down arrows directly to column labels in the list, so you can select the item you want to display. When you select an item from the drop-down list, Excel temporarily hides the rows that do not contain that item.

Your screen should then look like this:

Version 1.0

10

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

To select all the records containing Dawn as a Forename: • Click the arrow of the column containing the data you want to display, in this case Forename. A scrolling dialogue box is then displayed. • Select the item you want to display, in this case Dawn.

Your screen should then look like this:

Now practise using different filters. • When you have finished, restore the database by reselecting the AutoFilter command from the Filter submenu from the Data menu.

Version 1.0

11

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

7

FILTERING A LIST USING ADVANCED FILTER.

The Advanced Filter command enables you to filter data by using a criteria range to display only the rows that meet all the criteria you specify. The Advanced Filter allows you to either filter the list, in-place, which hides the rows that do not meet the criteria, or copy to another location, which copies the filtered data to another worksheet or another location on the same worksheet. You use Criteria to filter lists. There are two kinds of criteria you can use in a criteria range: Multiple comparison criteria to specify more than two comparison criteria for a single column. Computed criteria when your criteria are the result of calculation or require a comparison. Before you use the Advanced Filter you need to set up a Criterion range. Exercise. You are going to set up filters on your list using the contents of the Forename and Surname fields. In order to do this you need to firstly copy the relevant column headings to your selection criteria range, and secondly specify the selection criteria. The procedure for doing this is as follows: • Select cells B1 through C1, then choose the Copy command from the Edit menu. Then select cell H1 and choose the Paste command from the Edit menu. This has set up the selection criteria column headings which tells Excel which columns in the list to apply the selection criteria to. • Select cell I2 and type Anderson, to select all occurrences of Anderson as a surname. Your worksheet should look like:

Version 1.0

12

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

• Select any cell within your database (e.g. cell D1) and select the Advanced Filter command from the Filter submenu from the Data menu. Your screen should then look like this:

• Check that Filter the List in-place box is selected and the List Range is from cell A1 to F10 inclusive. • Specify the Criteria Range as cells H1 through I2 inclusive, either by directly entering the cell range, or by selecting the cells with the mouse. Your screen should then look like this:

• When you are satisfied that your filter criteria are correct, choose the OK button to select the matching records.

Version 1.0

13

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

Your screen should then look like this:

• To restore the database, select the Show All command from the Filter submenu from the Data menu.

Version 1.0

14

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

Now practise using different selection criteria. For example: To select all the people with a Forename of Dawn or a Surname of Anderson, type Anderson in cell I2 and Dawn in cell H3, and change the criteria range to cells H1 through I3 inclusive. To select all the people with a Forename of Dawn and a Surname of Anderson, type Anderson in cell I2 and Dawn in cell H2, and change the criteria range to cells H1 through I2 inclusive. To select all the people with a Forename of Dawn and a Surname of Anderson, or a Surname of Jarvis, type Anderson in cell I2 and Dawn in cell H2, and Jarvis in cell I3, and change the criteria range to cells H1 through I3 inclusive. Don’t forget to restore the database between each selection.

Version 1.0

15

December 1996

Aston Business School Student Guide - Excel version 5.0 Database Functions

8

SUMMARY.

In this exercise you have learned to: ∗ Construct a simple database (list) ∗ Add Data to the database ∗ Use Data Forms to Add, Change and Delete items on the database ∗ Change the sequence of the database using the Sort command ∗ Filtered the database using the Auto Filter and Advanced Filter options The AutoFilter command applies drop-down arrows directly to column labels in the list, so you can select the item you want to display. For example, you can display all the rows containing a specified unique value in a column, such as "all rows that contain Robinson in the Surname column." You can also use custom comparison criteria to filter the data in your list. When you hide rows using the AutoFilter, your worksheet is in Filter mode. In Filter mode, many Excel commands operate only on visible cells. After you filter a list to display the rows you want, you can copy the subset of your data to another location for further analysis. Use AutoFilter to filter the data in place, then use the Copy command and the Paste command to place the filtered data wherever you want it, even on another worksheet. Use Advanced Filter to apply complex criteria to filter your list, then automatically copy the filtered data to a location you specify. To copy the filtered data to another worksheet, it is easiest to filter the list by using AutoFilter. Then cut and paste the filtered data where you want it.

Version 1.0

16

December 1996