excel databases validation - acpcug.org-home · creating a new database in excel a database is an...

64
Working with Databases in Microsoft Excel

Upload: phamliem

Post on 04-Jun-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Working with Databases in Microsoft Excel

Page 2: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Creating a new database in Excel

A database is an organized set of information. It can contain

anything from the phone numbers in a rolodex to the data from a

research project. The typical database (Excel calls it a 'list') uses the

columns in a worksheet for the different pieces of information, also

called data elements or fields. The names of the fields are usually

entered on row 1 of the worksheet. Each row after 1 holds the data for

one subject or case in the database.

Working with databases involves two sets of activities. The

first set of activities involves creating the structure of the database and

entering the data into it with as few errors as possible. The second set

of activities involves reporting activities, or extracting information from

the database. This exercise focuses on the first set of activities

involved in creating a database.

Page 3: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Start a new workbook for the exercise

Creating Databases, Slide 3 Copyright © 2003, Jim Schwab, University of Texas at Austin

Open a new workbook in Microsoft Excel. If it has less than 2 worksheets, add worksheets to it.

To rename the workbook and save it in a directory where we can later find it, we complete the specifications in the Save Asdialog box. We will name the workbook AgencyClients.xls and save it in the StudentData folder. on the C:\ hard drive.

Page 4: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Specify the directory and name for the file

Creating Databases, Slide 4 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, if necessary, navigate to the directory C:\StudentData.

Second, we type the name of the file in the File name text box, AgencyClients.xls.

Third, click on the Savebutton to save the workbook in a file that has the new name.

When the file is saved, the dialog box will close and the new file name will be shown in the window title bar.

Page 5: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Change the name of Sheet1 to Demographics

Creating Databases, Slide 5 Copyright © 2003, Jim Schwab, University of Texas at Austin

When an application has multiple worksheets, giving the worksheets meaningful names makes it easier to keep track of what we are doing.

To change the name of Sheet1 to Demographics, select the Sheet|Renamecommand from the Formatmenu.

Page 6: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Type the new name for the worksheet

Creating Databases, Slide 6 Copyright © 2003, Jim Schwab, University of Texas at Austin

With the old name for the worksheet highlighted, we type Demographics, followed by the Enter key to replace the old name with the new name.

Page 7: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Enter the field names for the columns in the database

Creating Databases, Slide 7 Copyright © 2003, Jim Schwab, University of Texas at Austin

Type the descriptive field names for this data set in the first row of the worksheet. Type 'ID Number' in cell A1, 'Sex' in cell B1, 'Birth Date' in cell C1, and 'Marital Status' in cell D1.

Page 8: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Adjust width of columns so field names are fully visible

Creating Databases, Slide 8 Copyright © 2003, Jim Schwab, University of Texas at Austin

Part of the text of the field names is not visible because the columns are not wide enough to display the contents. We can adjust the widths of all of the columns so they are large enough to display their contents.

First, drag select columns Athrough D by clicking on the column letter A and dragging through the column letter D.

Second, select the Column|AutofitSelection command from the Format menu.

Page 9: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Freeze the field names so that they stay on the screen

Creating Databases, Slide 9 Copyright © 2003, Jim Schwab, University of Texas at Austin

After we have typed in seventeen rows of data, the field names will scroll off the screen when we go to row 18. We can prevent this by freezing their position on the worksheet.

First, to freeze the field names, we highlight the row beneath the row that we want to freeze. Click on row number 2 to select the entire row.

Second, we select the Freeze Panes command from the Window menu.

Page 10: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

The worksheet with a frozen field name pane

Creating Databases, Slide 10 Copyright © 2003, Jim Schwab, University of Texas at Austin

The only visible change that the frozen pane makes on the worksheet is the solid line beneath the frozen row holding the field names.

We can now scroll past the rows on the first screen without the field names disappearing from the worksheet.

Page 11: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Validating data entries in a database

Reporting on databases assumes that all the data was entered

correctly, an assumption that is not usually warranted because errors in

data entry are inevitable.

There are two strategies for reducing errors in data entry.

One is redundancy, in which we enter the same data twice on two

different worksheets and compare the entries cell by cell. If both cells

for an item agree, we conclude that the data is correct. If the cells

disagree, we decide which one is in error and make a correction.

Redundant data entry is expensive; we are doing the same task

twice. To try to avoid this replication, we can attempt to validate our

data entry as we go along. Validation involves checking a user's

answers as we go along, or letting the user select from a fixed list of

choices so that they cannot mistype an entry.

In this exercise, we will add data validation to our database.

Page 12: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Validation for the numeric variable ID Number

Creating Databases, Slide 12 Copyright © 2003, Jim Schwab, University of Texas at Austin

To validate the data for a field or column, we first click on the column letter to highlight the entire column.

Second, we select the Validation… command from the Data menu.

Page 13: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Selecting Whole number as the type of value for ID Number

Creating Databases, Slide 13 Copyright © 2003, Jim Schwab, University of Texas at Austin

The specification for ID Number is that it be a four digit number. Decimals are not permitted. To specify this requirement, we select 'Whole number' form the 'Allow' drop down list.

Page 14: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Specifying relationship for acceptable values of ID Number

Creating Databases, Slide 14 Copyright © 2003, Jim Schwab, University of Texas at Austin

The specification for a four digit number implies that the ID Number be a number between 1000 and 9999. We specify this with the between relationship from the Data drop down list.

Page 15: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Specifying the range of acceptable values for ID Number

Creating Databases, Slide 15 Copyright © 2003, Jim Schwab, University of Texas at Austin

With the between relationship selected, we first enter 1000 in the Minimum value text box.

Second, we enter 9999 in the Maximum value text box.

Third, we do not want a user to leave ID Number blank, so we clear the Ignore Blank checkbox.

Fourth, when we have completed the specifications for ID Number completed, we click on the Input Message tab to complete that item.

Page 16: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering the Input Message for ID Number

Creating Databases, Slide 16 Copyright © 2003, Jim Schwab, University of Texas at Austin

The 'Input Message' is a prompt or instruction that will appear when the user selects a cell in this column for data entry. The 'Input Message' has two parts: a title and a message.

First, we click on the Input Message tab to navigate to that page.

Second, we type the title which is the first line of the message, printed in bold type. Type in the name of the field 'ID Number'.

Third, we type in a message that informs the user what they are expected to enter, in this case 'Enter a four digit number'.

Fourth, when our input message is complete, click on the Error Alert tab to specify the computers response when the user enters incorrect data.

Page 17: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

The Error Alert for an incorrect ID Number

Creating Databases, Slide 17 Copyright © 2003, Jim Schwab, University of Texas at Austin

The error alert specifies the feedback given to the user when they have typed an incorrect entry. We can select a style for the dialog box that contains the feedback. Style controls the options the user is given when an incorrect entry is displayed. The 'Stop' stylerequires the user to retype the entry. The 'Warning' and 'Information' styles inform the user of the mistake, but allow the incorrect data to remain in the cell. The 'Title' and 'Error message' text boxes contain the text of the feedback to the user.

Page 18: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering the Error Alert for an incorrect ID Number

Creating Databases, Slide 18 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, click on the Error Alert tab to navigate to that page.

Second, we select the 'Stop' style for the alert box.

Third, we type in the Title of the window in which the alert message appears. We will use the name of the field: 'ID Number'.

Fourth, we type in the Error message which tells the user what to do to correct the error: 'The ID Number is the four digit number in the upper right hand corner of page 1 of the questionnaire'

Fifth, we click on the OK button to conclude our Data Validation entry.

Page 19: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Remove the validation for the ID Number field name

Creating Databases, Slide 19 Copyright © 2003, Jim Schwab, University of Texas at Austin

To remove the validation for a cell, we first click on the cell to select it.

Then, we select the Validation command from the Data menu.

Page 20: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Clear the validation from cell A1

Creating Databases, Slide 20 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, click on the Clear All button in the lower left-hand corner of the dialog box. It does not matter which page we are on in the dialog box.

Second, click on the OK button to complete the action.

Page 21: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Displaying the input prompt for ID Number

Creating Databases, Slide 21 Copyright © 2003, Jim Schwab, University of Texas at Austin

When we select a cell, e.g. A2, in the ID Numbercolumn, the Input Messageprompt appears.

Page 22: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering a correct ID Number

Creating Databases, Slide 22 Copyright © 2003, Jim Schwab, University of Texas at Austin

When we enter a correct ID Number, e.g. 1001, and press the enter key, Excel checks our input against the validation criteria. If our entry passes the test, Excel advances us to the next cell.

Page 23: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering an incorrect ID Number

Creating Databases, Slide 23 Copyright © 2003, Jim Schwab, University of Texas at Austin

When we enter an incorrect number for ID, e.g. 101 which is not between 1000 and 9999, Excel displays our Error Alert message.

We click on the Retry button and correct our entry.

Page 24: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

'Blanks' as a data entry error

We cleared the checkbox 'Ignore blank' as a data validation

setting because we did not the user to leave an ID Number blank. This

option does not appear to work as expected, because the definition of

what is a blank is ambiguous. If a user navigates to a new cell with the

Enter or arrow keys, no error message appears. If the user types blank

spaces in the cell (by pressing the spacebar), an error message will

appear. This error message appears because Excel's validation for this

cell converts the blanks to a number, decides they equal zero, and

finds that zero is outside the range from 1000 to 9999. If the user

deletes the blanks spaces, Excel will permit the user to go to the next

cell.

While I am certain that there are logical and reasonable

explanations for this behavior, it does pose the problem for us of how

to detect cells that were inadvertently left blank or empty. The

answer lies in Excel's auditing tool.

Page 25: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Leaving cells blank to test the auditing tool

Creating Databases, Slide 25 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, we deliberately leave cell A3 blank and enter correct data, e.g. 1003, in cell A4.

Second, we select the Show Formula Auditing Toolbar command from the Tools|Formula Auditing menu.

Page 26: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Circling invalid entries to detect data entry errors

Creating Databases, Slide 26 Copyright © 2003, Jim Schwab, University of Texas at Austin

The Formula Auditing tool bar is activated. Click on the Circle Invalid Data tool button.

Page 27: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Excel limits the number of errors it will show

Creating Databases, Slide 27 Copyright © 2003, Jim Schwab, University of Texas at Austin

Since we set ID Number validation for the entire column A, Excel checks the entire column. When it gets to 255 errors, it displays an error message.

Page 28: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Excel correctly detects the blank in cell A3

Creating Databases, Slide 28 Copyright © 2003, Jim Schwab, University of Texas at Austin

Our purpose in auditing the worksheet was to detect the blank cell A3 as an error. Excel has correctly circled A3. We should ignore all of the other red circles as extraneous information.To remove the red auditing circles, click on the 'Clear Validation Circles' tool button. To remove the auditing tool bar, click on its 'Close' box.

To remove the red auditing circles, click on the Clear Validation Circles tool button.

To remove the auditing tool bar, click on its Close box.

Page 29: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

The red auditing circles are removed

Creating Databases, Slide 29 Copyright © 2003, Jim Schwab, University of Texas at Austin

To close the formula auditing tool bar, click on its Closebox.

Enter correct data, 1002, in cell A3.

Page 30: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Validation for the text variable sex

Creating Databases, Slide 30 Copyright © 2003, Jim Schwab, University of Texas at Austin

To validate the data for a field or column, we first click on the column letter to highlight the entire column.

Second, we select the Validation command from the Data menu.

Page 31: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Select List as the type of data for Sex

Creating Databases, Slide 31 Copyright © 2003, Jim Schwab, University of Texas at Austin

The acceptable entries for Sex are Male and Female. When we have only a few optional responses, we can use a drop down list for data entry. Select List as the type of data to allow.

Page 32: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Specifying the acceptable list options for Sex

Creating Databases, Slide 32 Copyright © 2003, Jim Schwab, University of Texas at Austin

We first enter the response options as comma separated text, i.e. we type Male and Female in the Source text box, separated by a comma, i.e. Male,Female

Second, we mark the Ignore blank checkbox as we will treat blanks as missing data. Since we want a drop down list, we mark the In-cell dropdown checkbox.

Third, we click on the Input Message tab to enter specifications for that item.

Page 33: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering the Input Message for Sex

Creating Databases, Slide 33 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, we enter the field name Sex in the title which is the first line of the message, printed in bold type.

Second, we type in a message that informs the user what they are expected to enter: Select Male or Female from the drop down list

Third, since we expect our users to select from a menu, we do not expect them to mistype their entry. We will not include a specific error message. Click on the OK button.

Page 34: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Remove the validation for the Sex field name

Creating Databases, Slide 34 Copyright © 2003, Jim Schwab, University of Texas at Austin

To remove the validation for a cell, we first click on the cell to select it.

Then, we select the Validation command from the Data menu.

Page 35: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Clear the validation from cell B1

Creating Databases, Slide 35 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, click on the Clear Allbutton in the lower left-hand corner of the dialog box. It does not matter which page we are on in the dialog box.

Second, click on the OK button to complete the action.

Page 36: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Displaying the input prompt for Sex

Creating Databases, Slide 36 Copyright © 2003, Jim Schwab, University of Texas at Austin

When we select a cell, e.g. B2, in the Sex column, both the arrow for the drop down list and the Input Message prompt appear.

Page 37: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Selecting a value for Sex from the drop down list

Creating Databases, Slide 37 Copyright © 2003, Jim Schwab, University of Texas at Austin

We highlight our choice from the drop down menu and Excel fills in the cell with our choice.

Page 38: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

The Error Alert for an incorrect entry for Sex

Creating Databases, Slide 38 Copyright © 2003, Jim Schwab, University of Texas at Austin

If a user types an entry directly in the that does not match a choice on the list, e.g. Maninstead of Male, Excel displays its default error message because we did not specify an error alert for this column.

Click on Retry and correct the entry.

Page 39: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Validation for the date variable Birth Date

Creating Databases, Slide 39 Copyright © 2003, Jim Schwab, University of Texas at Austin

To validate the data for a field or column, we first click on the column letter to highlight the entire column.

Second, we select the Validation command from the Data menu.

Page 40: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Select Date as the type of data for Birth Date

Creating Databases, Slide 40 Copyright © 2003, Jim Schwab, University of Texas at Austin

We want to limit the user's entries for Birth Date to something that Excel can interpret as a date. Select the Date option from the list of allowable values.

Page 41: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Specifying the acceptable values of Birth Date

Creating Databases, Slide 41 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, we specify a between relationship for a range of values.

Second, we enter 1/1/1901 in the Start datetext box.

Third, we enter 12/31/2002 in the End date text box.

Fourth, we will accept a blank entry as missing data, so we mark the Ignore Blank checkbox.

Fifth, when we have completed the specifications for Birth Date completed, we click on the Input Messagetab to complete that item.

Page 42: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering the Input message for Birth Date

Creating Databases, Slide 42 Copyright © 2003, Jim Schwab, University of Texas at Austin

The Input Message will appear when the user selects a cell in this column for data entry.

First, we click on the Input Message tab to navigate to that page.

Second, we enter the title, Birth Date which will be first line of the message, printed in bold. Third, we type in a message

that informs the user what they are expected to enter: Enter a date between 1/11901 and 12/21/2002 in the format: mm/dd/yyyy

Fourth, when our input message is complete, click on the Error Alert tab to specify the computers response when the user enters incorrect data.

Page 43: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering the Error Alert for an incorrect Birth Date

Creating Databases, Slide 43 Copyright © 2003, Jim Schwab, University of Texas at Austin

When the user enters incorrect data, an Error Alert informs them of their error.

First, we select the Stop style for the alert box.

Second, we type in the title of the window in which the alert message appears.

Third, we type in a message which tells the user what they should do to correct the error: Please enter a date between 1/11901 and 12/21/2002 in the format: mm/dd/yyyy

Fourth, we click on the OK button to conclude our Data Validation entries.

Page 44: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Remove the validation for the field name

Creating Databases, Slide 44 Copyright © 2003, Jim Schwab, University of Texas at Austin

To remove the validatationfor a cell, we first click on the cell to select it.

Then, we select the Validation command from the Data menu.

Page 45: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Clear the validation from cell C1

Creating Databases, Slide 45 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, click on the Clear All button in the lower left-hand corner of the dialog box. It does not matter which page we are on in the dialog box. Second, click on the

OK button to complete the action.

Page 46: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering correct data for Birth Date

Creating Databases, Slide 46 Copyright © 2003, Jim Schwab, University of Texas at Austin

When we enter a value for Birth Date, Excel checks our answer to see if it passes the validation test. If it does, Excel advances to the next data entry cell.

Select cell C2 and enter 12/2/1968 as the birth date.

Page 47: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering alternative format of correct data for Birth Date

Creating Databases, Slide 47 Copyright © 2003, Jim Schwab, University of Texas at Austin

When we enter a value for Birth Date, Excel checks the date value, not the formatted value against the validation criteria. Thus, a valid date entered in an incorrect format, like Month Day, Year, will pass the validation test, e.g. March 12, 1967.

Page 48: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Excel accepts dates in alternate formats

Creating Databases, Slide 48 Copyright © 2003, Jim Schwab, University of Texas at Austin

Excel accepts anything that it can translate into a date, but it formats it in its default date format.

Page 49: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering incorrect data for Birth Date

Creating Databases, Slide 49 Copyright © 2003, Jim Schwab, University of Texas at Austin

An error for Birth Date will be an entry that Excel cannot interpret as a date, for example, a month name such as June.

Page 50: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Error response for an incorrect date

Creating Databases, Slide 50 Copyright © 2003, Jim Schwab, University of Texas at Austin

Excel checked our entry of June against allowable data including possible alternative formats for dates. When it could not make a match, it displayed the error message.

We click on the Retry button and correct our entry.

Page 51: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering incorrect data for Birth Date that Excel accepts

Creating Databases, Slide 51 Copyright © 2003, Jim Schwab, University of Texas at Austin

If we enter a number like a year, e.g. 1967, Excel accepts it as a valid date.

In its way of working with dates, Excel tracks dates as the number of days after January 1, 1900, making 1967 equivalent to May 20, 1905.

May 20, 1905 falls within our specified range from January 1, 1901 to December 31, 1999, so Excel accepts it as a valid entry.

Page 52: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Creating a list of acceptable entries for Marital Status

Creating Databases, Slide 52 Copyright © 2003, Jim Schwab, University of Texas at Austin

A drop down list may have more entries than can reasonably appear in the Source box for a validation list. In this case, we can enter the alternatives on a section of a worksheet and use that section as the source for the items in a drop down list.

First, we navigate to the Sheet2 worksheet and change its name to Codes.

Second, we type the response options in cells on this worksheet: type Never Married in cell A1, Married in cell A2, and Divorced in cell A3, Separated in cell A4, and Widowed in cell A5.

Page 53: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Naming the list of acceptable entries for Marital Status

Creating Databases, Slide 53 Copyright © 2003, Jim Schwab, University of Texas at Austin

A worksheet range can only be used as the source for a validation drop down list if it has a nameinstead of a cell reference.

To assign a name to cells A1:A5 on the Codesworksheet, we first highlight the five cells.

Second, we select the Name|Define command from the Insert menu.

Page 54: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Defining the name of the list

Creating Databases, Slide 54 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, we check the entry in the Refers totext box at the bottom of the dialog box to make sure it refers to the correct cells.

Second, we type the name MaritalCodes in the text box under the label Names in workbook.

Note: the names cannot contain any blanks

Page 55: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

The name of the list in the Name Box

Creating Databases, Slide 55 Copyright © 2003, Jim Schwab, University of Texas at Austin

When the named cells are all highlighted, their name instead of their cell reference will appear in the name box.

Page 56: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Validation for the text variable Marital Status

Creating Databases, Slide 56 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, navigate back to the Demographicsworksheet where the data will be entered.

Second, we first click on the column letter, D, to highlight the entire column.

Third, we select the Validation command from the Data menu.

Page 57: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Select List as the type of data for Marital Status

Creating Databases, Slide 57 Copyright © 2003, Jim Schwab, University of Texas at Austin

The acceptable entries for marital status are: Never Married, Married, and Divorced, Separated, and Widowed.

When we have a long list of items like this, we still use list validation, but we populate the list with items entered on a named section of a worksheet.

Page 58: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Specifying the acceptable list options for Marital Status

Creating Databases, Slide 58 Copyright © 2003, Jim Schwab, University of Texas at Austin

We first enter the response options as a reference to a named set of cells in the workbook, i.e. we type =MaritalCodes.

Do not forget the equal sign (=) at the beginning of the entry.

Second, we mark the Ignore blank checkbox as we will treat blanks as missing data. Since we want a drop down list, we mark the In-cell dropdown checkbox.

Third, we click on the Input Message tab to enter specifications for that item.

Page 59: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Entering the Input message for Marital Status

Creating Databases, Slide 59 Copyright © 2003, Jim Schwab, University of Texas at Austin

The Input Message will appear when the user selects a cell in this column for data entry.

First, we enter the title, which will be first line of the message, printed in bold.

Second, we type in a message that informs the user what they are expected to enter.

Third, since we expect our users to select from a menu, we do not expect them to mistype their entry. We will not include a specific error message. Click on the OK button.

Page 60: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Remove the validation for the Marital Status field name

Creating Databases, Slide 60 Copyright © 2003, Jim Schwab, University of Texas at Austin

To remove the validatationfor a cell, we first click on the cell to select it.

Then, we select the Validation command from the Data menu.

Page 61: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Clear the validation from cell D1

Creating Databases, Slide 61 Copyright © 2003, Jim Schwab, University of Texas at Austin

First, click on the Clear All button in the lower left-hand corner of the dialog box. It does not matter which page we are on in the dialog box. Second, click on the

OK button to complete the action.

Page 62: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Displaying the input prompt for marital status

Creating Databases, Slide 62 Copyright © 2003, Jim Schwab, University of Texas at Austin

When we select a cell, e.g. D2, in the Marital Status column, both the arrow for the drop down list and the Input Message prompt appear.

Page 63: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

Selecting a marital status from the drop down list

Creating Databases, Slide 63 Copyright © 2003, Jim Schwab, University of Texas at Austin

We highlight our choice from the drop down menu and Excel fills in the cell with our choice.

Page 64: ExceL Databases Validation - ACPCUG.org-Home · Creating a new database in Excel A database is an organized set of information. It can contain anything from the phone numbers in a

A marital status in the worksheet

Creating Databases, Slide 64 Copyright © 2003, Jim Schwab, University of Texas at Austin

The marital status selected from the drop down list is shown in the cell.