Excel XP Level 4 Vicon

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 176

Microsoft Excel XP

Level 4
ABOUT VICON
Vicon Learning Systems (VLS), the parent company of JaxWorks.com, provides computer
training products and services with a focus on helping its customers improve productivity through
the successful implementation of technology.

The training materials are for the students' use both during the self-administered course and as a
reference guide.

For more information and a list of other available products, please visit us at our web site at
www.jaxworks.com.

COPYRIGHT & TRADEMARKS


Copyright © 2004 by Vicon Learning Systems. All rights reserved. Information in this document
is subject to change without notice and does not represent a commitment on the part of Vicon
Learning Systems.

Trademarked names appear throughout this book. Rather than list the names and entities that own
the trademarks or insert a trademark symbol with each mention of the trademark name, Vicon
Learning Systems states that it is using the names for editorial purposes and to the benefit of the
trademark owner with no intention of infringing upon the trademark.

DISCLAIMER
Vicon Learning Systems made every effort to ensure the accuracy of this manual. If you should
discover any discrepancies, please notify us immediately at:

www.jaxworks.com/feedback.htm

Vicon Learning Systems


MICROSOFT EXCEL XP LEVEL 4

ABOUT VICON .......................................................................................................... I

COPYRIGHT & TRADEMARKS............................................................................ I

DISCLAIMER ............................................................................................................ I

LESSON 1 - USING OTHER FUNCTIONS...........................................................1


Using Function Arguments.......................................................................................2
Using Financial Functions........................................................................................3
Using Logical Functions...........................................................................................6
Using Date Functions .............................................................................................10
Formatting Dates ....................................................................................................13
Revising Formulas..................................................................................................15
Exercise ..................................................................................................................17
Using Other Functions .......................................................................................17

LESSON 2 - USING RANGE NAMES ..................................................................19


Working with Range Names ..................................................................................20
Jumping to a Named Range....................................................................................20
Assigning Names....................................................................................................22
Using Range Names in Formulas ...........................................................................24
Creating Range Names from Headings ..................................................................25
Applying Range Names..........................................................................................27
Deleting Range Names ...........................................................................................29
Using Range Names in 3-D Formulas....................................................................31
Creating 3-D Range Names....................................................................................33
Using 3-D Range Names in Formulas....................................................................34
Exercise ..................................................................................................................37
Using Range Names ...........................................................................................37

LESSON 3 - USING ADVANCED FUNCTIONS ................................................39


Using Lookup Functions ........................................................................................40
Using the VLOOKUP Function .............................................................................40
Using the HLOOKUP Function .............................................................................43
Using the IF Function.............................................................................................46

Vicon Learning System Page iii


Using Nested IF Functions .....................................................................................49
Using the ISERROR Function................................................................................52
Using an AND Condition with IF...........................................................................54
Using an OR Condition with IF..............................................................................56
Using the ROUND Function ..................................................................................57
Limiting the Precision of Numbers ........................................................................60
Exercise ..................................................................................................................63
Using Advanced Functions ................................................................................63

LESSON 4 - USING DATA TABLES....................................................................65


Using Data Tables ..................................................................................................66
Placing Formulas in Data Tables............................................................................66
Creating a One-Variable Table...............................................................................67
Creating a Two-Variable Table ..............................................................................69
Exercise ..................................................................................................................72
Using Data Tables ..............................................................................................72

LESSON 5 - USING MACROS ..............................................................................73


Defining Macros.....................................................................................................74
Opening a Workbook Containing Macros..............................................................74
Running a Macro ....................................................................................................76
Using a Shortcut Key..............................................................................................78
Using the Visual Basic Toolbar..............................................................................79
Opening the Visual Basic Editor Window .............................................................80
Using the Visual Basic Editor Window..................................................................82
Exercise ..................................................................................................................84
Using Macros .....................................................................................................84

LESSON 6 - RECORDING MACROS..................................................................85


Recording a Macro .................................................................................................86
Assigning a Shortcut Key .......................................................................................88
Using Relative References......................................................................................90
Assigning a Macro to a Menu ................................................................................92
Removing a Custom Menu Item.............................................................................94
Deleting a Macro ....................................................................................................95
Exercise ..................................................................................................................97
Recording Macros ..............................................................................................97

Page iv Vicon Learning System


LESSON 7 - EDITING MACROS .........................................................................99
Writing a New Macro...........................................................................................100
Entering Macro Comments...................................................................................101
Copying Macro Commands..................................................................................103
Editing Macro Commands....................................................................................104
Typing Macro Commands....................................................................................106
Running a Macro from the Code Window ...........................................................108
Exercise ................................................................................................................110
Editing Macros .................................................................................................110

LESSON 8 - USING CUSTOM TOOLBARS AND MENUS ............................113


Creating a Custom Toolbar ..................................................................................114
Adding/Removing Toolbar Buttons .....................................................................115
Adding the Custom Button to a Toolbar ..............................................................116
Assigning a Macro to a Button.............................................................................118
Changing a Button Image.....................................................................................119
Displaying Button Text and Image.......................................................................120
Attaching a Custom Toolbar ................................................................................122
Deleting a Custom Toolbar ..................................................................................123
Creating a Custom Menu......................................................................................125
Adding Custom Menu Commands .......................................................................127
Exercise ................................................................................................................130
Using Custom Toolbars and Menus .................................................................130

LESSON 9 - CREATING A MACRO BUTTON................................................133


Using a Macro Button ..........................................................................................134
Creating a Macro Button ......................................................................................134
Copying a Macro Button ......................................................................................136
Formatting a Macro Button ..................................................................................137
Moving/Sizing a Macro Button ............................................................................138
Deleting a Macro Button ......................................................................................139
Exercise ................................................................................................................141
Creating a Macro Button ..................................................................................141

LESSON 10 - USING WORKSHEET PROTECTION......................................143


Unlocking Cells in a Worksheet...........................................................................144
Protecting a Worksheet.........................................................................................145

Vicon Learning System Page v


Unprotecting a Worksheet ....................................................................................147
Creating Allow-Editing Ranges............................................................................148
Deleting Allow-Editing Ranges............................................................................151
Protecting Workbook Windows ...........................................................................152
Unprotecting Workbook Windows.......................................................................154
Assigning a Password...........................................................................................155
Opening a Password-protected File......................................................................157
Removing a Password ..........................................................................................159
Setting Manual Calculation ..................................................................................160
Resetting Automatic Calculation..........................................................................162
Using the Document Recovery Pane ....................................................................163
Exercise ................................................................................................................164
Using Worksheet Protection.............................................................................164

INDEX......................................................................................................................165

Page vi Vicon Learning System


LESSON 1 -
USING OTHER FUNCTIONS

In this lesson, you will learn how to:


• Use function arguments

• Use financial functions

• Use logical functions

• Use date functions

• Format dates

• Revise formulas
Lesson 1 - Using Other Functions Excel XP Level 4

USING FUNCTION ARGUMENTS

δ Discussion
Excel functions serve as shortcuts for worksheet computations. A function is a
prewritten formula that takes one or more values, performs an operation on them, and
returns a value. Functions simplify and shorten formula creation by performing
lengthy or complex calculations with a single command.

The values that a function uses to perform a calculation are called arguments.
Arguments can consist of cell addresses, values, text, cell names, or a combination
thereof. Other functions can also be used as arguments; this is known as nesting
functions.

Functions require a set of parentheses around the function itself. More complex
functions may also require additional sets of parentheses around the arguments within
it. No matter how many sets of parentheses are included in a function, they must
always appear in pairs; if you include an opening parenthesis without a matching
closing parenthesis or vice versa, Excel cannot calculate the function and will display
an error message.

The syntax of a function is its required structure; if the syntax of a function is not
correct, Excel cannot perform the calculation. The basic function syntax requires an
equal sign (=), the function name, the opening parenthesis, the required arguments,
and the closing parenthesis.

The Insert Function dialog box provides an easy and accurate method of creating a
function containing several arguments. This dialog box allows you to browse
functions and view an explanation of each one. When you select a function, the
Function Argument dialog box opens and guides you in creating the function
arguments in their proper order.

ο Text can be used as a function argument. When text is used in


a function, it must be enclosed in quotation marks.

ο Function tooltips are provided to help you in creating


functions. A function tooltip displays the function syntax and
appears as soon as you type the equal sign, the name of the
function, and the opening parenthesis.

Page 2 Vicon Learning System


Excel XP Level 4 Lesson 1 - Using Other Functions

USING FINANCIAL FUNCTIONS

δ Discussion
Excel organizes its functions into categories. The Financial category includes a large
number of functions that can be used to create calculations such as the payment on a
loan, the interest rate on an investment or loan, the interest payment on an investment
over time, and the future value of an annuity or investment.

Financial function arguments must be entered in the proper order. Most financial
functions include required arguments and additional optional arguments. The
definitions of some common financial functions and the syntax of their required
arguments are listed in the following table:

Function Syntax
PMT (Payment) calculates the payment on a =PMT(rate,nper,pv)
loan, such as a mortgage, based on a constant
interest rate payment.
FV (Future Value) calculates the value an =FV(rate,nper,pmt)
annuity will be worth given a series of
payments invested at an interest rate over a
specified period.
PV (Present Value) calculates the current value =PV(rate,nper,pmt)
of a series of payments.
RATE calculates the interest rate of periodic =RATE(nper,pmt,pv)
payments to an annuity or loan.

Some of the common arguments required by financial functions are defined in the
following table:

Arguments Definition
rate The amount of interest charged yearly for a loan or
investment. The interest can be entered as a decimal or
percentage. For example, 10% can be entered as 0.1 or
10%.
nper The number of payments it will take to repay the loan or
investment.
pv The value an annuity is worth at the present time if a
series of future payments are made. In the case of a loan,
this would be the full amount of the loan. You should be
careful not to include a comma in the amount.

Vicon Learning System Page 3


Lesson 1 - Using Other Functions Excel XP Level 4

Arguments Definition
fv The value that an annuity will be worth in the future
after the last payment has been made. You should be
careful not to include a comma in the amount.
pmt A fixed payment made each period.

The entries for rate and nper should be in consistent units. When calculating the
payment on a loan of $170,000 at 10% annual interest over 30 years, the result of the
function =PMT(10%,30,170000) is payments of approximately $18,000 per year. To
calculate the monthly payments, divide the interest rate by 12 and multiply the
number of payment periods by 12. The result of the function
=PMT(10%/12,30*12,170000) is payments of approximately $1,500 per month.

Creating a financial function

φ Step-by-Step
From the Student Data directory, open ADVFNCT.XLS.
Use a financial function.

If necessary, display the Financial worksheet.

Use the PMT function to calculate the annual payment for a loan.

Page 4 Vicon Learning System


Excel XP Level 4 Lesson 1 - Using Other Functions

Steps Practice Data


1. Select the cell into which you want to Click cell D15
enter the formula.
The active cell moves accordingly.
2. Click the Insert Function button on
the formula bar. Click
The Insert Function dialog box opens.
3. Select the Or select a category list. Click Or select a
A list of available categories appears. category
4. Select Financial. Click Financial
The Select a function list box displays
all available financial functions.
5. Select the desired function from the Scroll as necessary and
Select a function list box. click PMT
The function is selected, and a
description of the function appears
below the Select a function list box.
6. Select OK. Click OK
The Insert Function dialog box closes,
and the Function Arguments dialog
box opens.
7. Click the Collapse Dialog button to
Click Rate
the right of the first argument in the
Function Arguments dialog box.
The Function Arguments dialog box
collapses.
8. Select the cells you want to use for the Click cell B14
first argument.
The cell address appears in the
collapsed Function Arguments dialog
box.
9. Click the Expand Dialog button to
Click
redisplay the Function Arguments
dialog box.
The Function Arguments dialog box
expands.
10. Continue entering arguments as Follow the instructions
needed. shown below the table
The cell address or value appears in before continuing on to
each argument box accordingly, and the next step
the result of the formula appears in the
lower section of the Function
Arguments dialog box.

Vicon Learning System Page 5


Lesson 1 - Using Other Functions Excel XP Level 4

Steps Practice Data


11. Select OK. Click OK
The Function Arguments dialog box
closes, and the result of the formula
appears in the active cell.

Type the following cell references into the corresponding argument boxes:

Enter B15 into the Nper box and B13 into the Pv box.

Return to the table and continue on to the next step.

The results should be a payment of negative $72,252 per year. (The parentheses
around the payment indicate a negative value. The result is negative because it is
money to be paid (a loss) rather than money to be received (profit).)

Practice the Concept: Scroll down to view rows 25 to 38. Select cell D37. Use the
FV function to calculate the future value of the investment. Your results should be
(positive) $543,042.

USING LOGICAL FUNCTIONS

δ Discussion
Logical functions make decisions based on criteria. If the criteria evaluates to false,
one action is taken; if the criteria evaluates to true, a different action is taken. This
decision-making capability makes logical functions one of the most powerful groups
of functions in Excel.

Logical functions can be applied to many different situations. For example, if a


salesperson meets his or her quota, he or she can get a bonus in addition to his or her
regular commission. You can use a logical function to test whether or not the sales are
greater than the quota. If the sales are greater, the function adds the bonus to the
commission; if not, the bonus is not added to the commission.

The IF function returns one value if a condition is true and another value if a
condition is false. For example, you can compare the values of goods shipped to a
customer. If a shipped value is greater than a set figure, the customer receives a
discount. If a shipped value is less than a set figure, the customer does not receive a
discount.

You can also use the IF function to display text as a result of a logical test, but you
must enclose the text in the formula in quotation marks.

The syntax of an IF function is:

Page 6 Vicon Learning System


Excel XP Level 4 Lesson 1 - Using Other Functions

=IF(logical test,value if true,value if false)

The IF function arguments are described in the following table:

Component Description
logical test This component is the test condition. It can contain
cell references, text in quotes, cell names, and
numbers. You can use one or more of the following
comparison operators:
= equal to
<> not equal to
> greater than
>= greater than or equal to
< less than
<= less than or equal to
value if true The result produced if the logical test is true. It can
be a number, formula, cell reference, cell name, text
in quotes, or another function.
value if false The result produced if the logical test is false. It can
be a number, formula, cell reference, cell name, text
in quotes, or another function.

Some examples of the IF function are listed in the following table:

IF Function Result
=IF(B7>10,C7*.1,0) The function tests if the number in
cell B7 is greater than 10. If this is
true, the number in cell C7 is
multiplied by 0.1 and the result is
entered into the current cell. If it is not
true, a zero is entered into the current
cell.
=IF(B7<>10,"GOOD","NO The function tests if the number in
GOOD") cell B7 is not equal to 10. If this is
true, the text GOOD is entered into
the current cell. If the number in cell
B7 is equal to 10, the text NO GOOD
is entered into the current cell.

Vicon Learning System Page 7


Lesson 1 - Using Other Functions Excel XP Level 4

Creating an IF function

ο If you want a function to display a blank cell as the result of


either the true or false argument, you can enter two quotation
marks with no intervening text (“”). For example, if you use
the function, =IF(B6>10,"GOOD",""), no message will
display if cell B6 is not greater than 10.

φ Step-by-Step
Use a logical function.

Display the Logical worksheet.

Customers receive a 10% discount on all orders above $400. Use the IF function to
determine if the order is greater than $400. If the order is greater than $400, calculate
10% of the order; if it is not, there is no discount.

Steps Practice Data


1. Select the cell where you want the Click cell F14
result of the IF function to appear.
The cell is selected.

Page 8 Vicon Learning System


Excel XP Level 4 Lesson 1 - Using Other Functions

Steps Practice Data


2. Type =if and an open parenthesis ( ( ). Type =if(
The text =if( appears in the cell and on
the formula bar.
3. Type the logical test. Type F13>400
The argument appears in the cell and
on the formula bar.
4. Type a comma ( , ) to separate the Type ,
arguments.
The comma ( , ) appears in the cell
and on the formula bar.
5. Type the action to be taken if the Type F13*.1
logical test is true.
The text appears in the cell and on the
formula bar.
6. Type a comma ( , ) to separate the Type ,
arguments.
The comma ( , ) appears in the cell
and on the formula bar.
7. Type the action to take if the logical Type 0
test is false.
The argument appears in the cell and
on the formula bar.
8. Type a closing parentheses ( ) ). Type )
The closing parenthesis ( ) ) appears
in the cell and on the formula bar.
9. Press [Enter]. Press [Enter]
The result of the IF function appears
in the cell.

Since the order is over $400, the customer receives a discount of $41.95.

Practice the Concept: Select cell F18 and create an IF function that displays the
message You have earned a 10% discount if the order is over $400. Otherwise, no
message is displayed. Use the following IF function to create the message:
=IF(F13>400,"You have earned a 10% discount","").

In the QTY column, select cell C9 and change the quantity to 5. The order now falls
below $400. Notice that the customer does not receive a discount and no message
appears below the order form. Change the quantity in cell C10 to 20 and view the
changes.

Vicon Learning System Page 9


Lesson 1 - Using Other Functions Excel XP Level 4

USING DATE FUNCTIONS

δ Discussion
When you enter a date into a cell, Excel formats the date and stores it as the serial
number that represents that date on the calendar. Excel treats dates as numbers so that
it can perform calculations on them, such as determining how many days a bill is past
due.

You can either type a specific date into a worksheet or use a date function to enter a
date. For example, you can enter the same date by typing 2/20/99 or by entering the
function =DATE(1999,2,20). The date function is often used when the year, day, and
month information already exist in separate cells in the worksheet.

Excel also provides a date function that inserts the current date as a field that
automatically updates each time you open the workbook. Some formulas require an
updated current date to increment. For example, to calculate a person’s age, you need
two dates: the birth date and the current date. The birth date is an absolute date, since
that date cannot change. The current date, however, would have to change each day
for the formula to calculate the result correctly.

Similarly, to calculate how many days a bill is past due, you also need two dates: the
date when the bill was due and the current date. The date when the bill was due is an
absolute date, since that date does not change. The current date, however, would have
to change each day for the formula to calculate the result correctly .

The most commonly used date functions are described in the following table:

Function Description
=DATE(year,month,day) The DATE function is used to enter a
specific date into a cell. You enter the
number of the month, day, and year as the
arguments. You can also reference cell
addresses, if one or more arguments are
stored in a cell.
=TODAY() The TODAY function displays the current
date in a date format. This function does
not use arguments. The serial number for
this function is a whole number.
=NOW() The NOW function displays the current
date and time in a date format. This
function does not use arguments. The
serial number for this function displays
the time of day as a decimal.

Page 10 Vicon Learning System


Excel XP Level 4 Lesson 1 - Using Other Functions

Creating a DATE function

ο If you type a year between 1900 and 1929 as two digits, Excel
assumes that the date is in the 21st century. Therefore, typing
2/13/25 returns the serial number for the date 2/13/2025. You
must type all four digits to designate any years between 1900
and 1929.

ο You can also calculate time of day values. Time of day values
can be formatted using the Time category on the Number
page in the Format Cells dialog box.

φ Step-by-Step
Use a date function.

Display the Dates worksheet.

Vicon Learning System Page 11


Lesson 1 - Using Other Functions Excel XP Level 4

Steps Practice Data


1. Select the cell into which you want to Click cell E17
enter the formula.
The active cell moves accordingly.
2. Click the Insert Function button on
the formula bar. Click
The Insert Function dialog box opens.
3. Select the Or select a category list. Click Or select a
A list of available categories appears. category
4. Select Date & Time. Click Date & Time
The Select a function list box displays
all available date and time functions.
5. Select the desired function from the Click DATE, if necessary
Select a function list box.
The function is selected, and its syntax
and description appear in the lower
section of the Insert Function dialog
box.
6. Select OK. Click OK
The Insert Function dialog box closes,
and the Function Arguments dialog
box opens.
7. Type the value or select the cell for the Type 1997
first argument.
The cell address or value appears in
the first argument box.
8. Continue entering arguments as Follow the instructions
necessary. shown below the table
The cell address or value appears in before continuing on to
each argument box accordingly, and the next step
the formula result appears in the lower
section of the Function Arguments
dialog box.
9. Select OK. Click OK
The Function Arguments dialog box
closes, and the result of the formula
appears in the cell.

Enter 6 in the Month argument box and 20 in the Day argument box.

Return to the table and continue on to the next step.

Page 12 Vicon Learning System


Excel XP Level 4 Lesson 1 - Using Other Functions

Practice the Concept: Type the =NOW() function into cell C3 to insert the current
date and time as a field that automatically updates whenever the workbook
recalculates. There are no arguments for this function.

Select cell F6 and create a formula that calculates the length of employment, in years,
for the first employee. The formula should read =($C$3-E6)/365. (Cell C3 must be
entered as an absolute reference, since all hire dates must be subtracted from the
current date to achieve the desired result. Since the answer provides the length of
employment in days, the result is divided by 365 to calculate the number of years.)

Decrease the number of decimals to 1 and then copy the formula down to cell F17.

FORMATTING DATES

δ Discussion
The default formatting used by Excel for dates, times, currency, and numbers is a
Windows function controlled by the Regional Options dialog box in Windows 2000,
or the Regional Settings Properties dialog box in Windows 95/98.

If the default short date format for your system is M/d/yy, then Excel uses this format
for dates and only displays the last two digits of the year. Therefore, even if you type
3/11/2001 into a cell or use the DATE function =DATE(2001,3,11), the cell displays
3/11/01. If you want to display all four digits of the year in a date, you can either
change the default system format or format the worksheet cell containing the date.

In addition to the short date format, there are many other preset formats available on
the Number page of the Format Cells dialog box.

Formatting a date

Vicon Learning System Page 13


Lesson 1 - Using Other Functions Excel XP Level 4

ο You can change your default system settings by opening the


Control Panel and selecting the Regional Options (Windows
2000) or Regional Settings (Windows 95/98) icon.

φ Step-by-Step
Format dates.

If necessary, display the Dates worksheet.

Steps Practice Data


1. Select the cell you want to format. Click cell C3
The cell is selected.
2. Select the Format menu. Click Format
The Format menu appears.
3. Select the Cells command. Click Cells...
The Format Cell dialog box opens.
4. Select the Number tab. Click the Number tab, if
The Number page appears. necessary
5. Select Date from the Category list Click Date
box.
A list of available date formats
appears in the Type list box.
6. Select the desired format from the Scroll as necessary and
Type list box. click 3/14/2001
The format is selected and a preview
appears under Sample.
7. Select OK. Click OK
The Format Cells dialog box closes,
and the date format is applied to the
selection.

Page 14 Vicon Learning System


Excel XP Level 4 Lesson 1 - Using Other Functions

REVISING FORMULAS

δ Discussion
You can revise a formula or function in the same manner you would edit any cell. You
can modify the cell addresses, arguments, operators, or even the name of the function
used. Formulas are often revised to create an absolute reference for one or more cell
addresses. Revising a formula is usually more efficient than creating the formula
again.

You can revise a formula in the formula bar or in the cell itself, using standard word
processing methods. When you edit a function, a tooltip appears. You can use the
tooltip to quickly select the text of the argument you want to edit.

Revising a formula

ο You can also use the Insert Function button on the formula
bar to edit a function.

φ Step-by-Step
Revise a formula.

If necessary, display the Dates worksheet.

Vicon Learning System Page 15


Lesson 1 - Using Other Functions Excel XP Level 4

Steps Practice Data


1. Double-click the cell containing the Double-click cell E6
formula you want to revise.
The formula appears in the cell and on
the formula bar.
2. Click the argument you want to edit in Click day in the tooltip
the tooltip, or select the formula text
you want to revise.
The argument is selected, or the
insertion point appears in the formula.
3. Revise the text as desired. Type 28
The revision appears in the cell and on
the formula bar.
4. When you have finished revising the Press [Enter]
formula, press [Enter].
The formula and its result change
accordingly.

Close ADVFNCT.XLS.

Page 16 Vicon Learning System


Excel XP Level 4 Lesson 1 - Using Other Functions

EXERCISE
USING OTHER FUNCTIONS

ε Task
Use financial, logical, and date functions.

1. Open Advfnex.
2. Display the Financial worksheet, if necessary. Create an NPER
function in cell D16 to calculate the number of years it will take for
the annuity to be worth $500,000. (Hint: Use the Insert Function
button to help you with the order of the arguments.)
3. Scroll down to view rows 24 to 39.
4. Use the PMT function in cell D39 to determine the monthly
mortgage payments. (Hint: You need to divide the interest rate by 12
and multiple the number of years, nper, by 12.)
5. Display the Logical worksheet. Create an IF function in cell H6 to
calculate a bonus if the Qtr2 sales is greater than the Qtr1 sales.
Salespeople receive a bonus of 8% of their Qtr2 sales if they exceed
the Qtr1 sales; otherwise, they do not receive a bonus.
6. Copy the formula down to the range H7:H12.

Vicon Learning System Page 17


Lesson 1 - Using Other Functions Excel XP Level 4

7. Display the Date worksheet. Use the DATE function to enter the
date June 20, 2001 in cell B4.
8. Use the NOW function to enter the current date in cell B6.
9. Select cell B10 and use the DATE function to enter yesterday’s date.
10. Copy cell B10 to cell B11. Change the month argument in cell B11
to the previous month.
11. Change the format for the range B4:B12 to the 14-Mar-2001 format.
12. Select cell C10 and calculate the number of days worked on the
booth by subtracting the starting date from the current date. (Hint:
Make the current date in cell B6 an absolute reference so that you
can copy it.)
13. Format the answer in cell C10 with a number format and one
decimal place. Then, copy the formula to C11.
14. Close the workbook without saving it.

Page 18 Vicon Learning System


LESSON 2 -
USING RANGE NAMES

In this lesson, you will learn how to:


• Work with range names

• Jump to a named range

• Assign names

• Use range names in formulas

• Create range names from headings

• Apply range names

• Delete range names

• Use range names in 3-D formulas

• Create 3-D range names

• Use 3-D range names in formulas


Lesson 2 - Using Range Names Excel XP Level 4

WORKING WITH RANGE NAMES

δ Discussion
You can assign a name to a cell or a range in a worksheet. Once a name has been
assigned, the name can be used in any instance where you can use a cell address. For
example, you can use names for ranges in dialog boxes and formulas.

Advantages to using names instead of cell addresses include:

1. Names reduce the chance of error in formulas. It is easy to


recognize if the name EXPENSES is typed incorrectly. If a cell or
range address is typed incorrectly, it is harder to detect.
2. Names adapt to changes within a range (for example, when rows
and columns are added to or removed from the range).
3. Names are easy to recognize and maintain in formulas. For example,
the formula =TOTALSALES-EXPENSES is easier to understand
than the formula =E3-F3.
4. You can easily move the active cell to a named cell or range using
the Name box.
5. Names created in one worksheet are available to all other
worksheets in the workbook.
6. Names can refer to non-contiguous ranges or to ranges that contain
blank cells, columns, or rows.
7. Names are absolute. If you use a name in a formula, the formula
always refers to that range, even if you copy or move the formula.

You can use names to refer to cells, ranges, multiple ranges, and ranges in other
worksheets.

JUMPING TO A NAMED RANGE

δ Discussion
You can use a name to move quickly to a cell or a range. Since a name assigned in a
worksheet is available in all worksheets in the workbook, you can use names to move
easily between the worksheets. For example, in a workbook containing worksheets for
different products, you can quickly jump to the desired product worksheet using the
name assigned to it.

Page 20 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

You use the Name Box list to jump to a named range. The Name Box list is located at
the left end of the formula bar and displays all the assigned names in a workbook.
When you choose a name from the Name Box list, the range is selected and the active
cell appears in the first cell of the range.

Jumping to a named range

ο If the formula bar is not displayed, you can use the View menu
to view it.

φ Step-by-Step
From the Student Data directory, open NAME1.XLS.
Jump to a named range.

Steps Practice Data


1. Click the arrow for the Name Box list Click Name
on the formula bar.
A list of available named ranges
appears.
2. Select the name of the desired range. Click Qtr4_NetProfits
The range appears.

Vicon Learning System Page 21


Lesson 2 - Using Range Names Excel XP Level 4

Notice that the active cell moved to the Qtr 4 worksheet. Use the Qtr1_NetProfits
name on the Name Box list to return to the Qtr 1 worksheet.

ASSIGNING NAMES

δ Discussion
You can use names instead of cell references in formulas and dialog boxes. For
example, if you are summing totals from several worksheets, you can assign names to
the totals in each worksheet and then use the range names in the formula instead of the
cell addresses.

You can use the Name Box to assign range names. The following rules apply to
naming ranges:

1. Names must start with a letter or an underscore. The remainder of the


name can contain any character except a space or a hyphen. Avoid
using the dollar sign ($), since it may be confused with an absolute
reference.
2. Names can be up to 255 characters long. You should keep them short
to make them easy to use and to conserve space in formulas (which
also have a maximum length of 255 characters).
3. Names are not case-sensitive. They can be typed in either uppercase
or lowercase.
4. You should not use names that resemble cell references (such as Q1).

Page 22 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

Assigning a name to a cell

φ Step-by-Step
Assign a name to a range.

If necessary, go to the Qtr 1 worksheet.

Steps Practice Data


1. Select the cell or range you want to Click cell E8
name.
The range is selected.
2. Click in the Name Box on the formula Click in the Name Box
bar.
The text in the Name Box is selected.
3. Type the desired name. Type Qtr1_Total
The text appears in the Name Box.
4. Press [Enter]. Press [Enter]
The name is saved and appears in the
Name Box.

Vicon Learning System Page 23


Lesson 2 - Using Range Names Excel XP Level 4

USING RANGE NAMES IN FORMULAS

δ Discussion
You can use a name rather than a cell address in a formula. Using a name in a formula
makes the formula easier to read and understand. For example, it is easy to understand
what information the following formula calculates; =INCOME-EXPENSES. If the
named cells change, the formula automatically updates.

Since names are absolute, you can use a name in place of an absolute cell reference in
a formula. For example, if you are calculating a percentage of a range named Total,
the formula will always refer to the Total range if you use the name rather than the
cell address, no matter where you move or copy the formula.

Using range names in a formula

ο You can also select a name from the Paste Name dialog box to
insert a name into a formula. To use the Paste Name dialog
box, begin the formula. When you need to reference the name
in the formula, press the [F3] key and double-click the desired
name.

ο You can also access the Paste Name dialog box while creating
a formula by selecting the Insert menu, the Name command
and the Paste command.

Page 24 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

φ Step-by-Step
Use a range name in a formula.

If necessary, go to the Qtr 1 worksheet.

Steps Practice Data


1. Select the cell in which you want the Click cell I4
result of the formula to appear.
The cell is selected.
2. Start typing the formula or function. Type =E4/
The formula appears in the cell and on
the formula bar.
3. Type the desired name at the Type Qtr1_Total
appropriate location in the formula.
The name appears in the cell and on
the formula bar.
4. Press [Enter]. Press [Enter]
The result of the formula appears in
the cell.

Practice the Concept: Select cell I5, type =E5/ and press [F3]. Then select
Qtr1_Total, click OK, and press [Enter] to complete the formula. Copy the formula
to the range I6:I7. Click cells I6 and I7. Notice that the name did not change when you
copied the cell.

CREATING RANGE NAMES FROM HEADINGS

δ Discussion
You can create names for rows and columns using text entered into the first or last cell
of the row or the top or bottom cell of the column. This option is a quick way to create
names that correspond directly to worksheet entries. For example, in a worksheet
containing the quantity of products sold each month, you can use the product names in
the row headings to name the rows of quantities sold.

When Excel names rows and columns from headings, it uses the text in the indicated
location (i.e., the top, bottom, right or left cell) to name the selected range. The cells
containing the text are not included in the named ranges. You can create multiple
names at the same time by selecting a range that spans several columns or rows.

Vicon Learning System Page 25


Lesson 2 - Using Range Names Excel XP Level 4

Creating range names from headings

ο Although the text in the header columns and rows is not


included in the named ranges, it must be included in the range
you select prior to performing the command in order for Excel
to determine the range names.

φ Step-by-Step
Create range names from headings.

If necessary, go to the Qtr 1 worksheet.

Steps Practice Data


1. Select the range you want to name, as Drag B3:G7
well as the row or column heading
containing the desired range names.
The range is selected.
2. Select the Insert menu. Click Insert
The Insert menu appears.
3. Point to the Name command. Point to Name
The Name submenu appears.

Page 26 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

Steps Practice Data


4. Select the Create command. Click Create...
The Create Names dialog box opens.
5. Under Create names in, select the Click Top row, if
option corresponding to the location of necessary
the desired names.
The option is selected.
6. Select OK. Click OK
The Create Names dialog box closes,
and the names are created from the
row and/or column headings.

Display the Name Box list on the formula bar; notice that a name was created for each
heading in the range. Select the Feb name. Click any cell to deselect the range.

APPLYING RANGE NAMES

δ Discussion
After you have named a range, you can use it in existing formulas. For example, after
you have created formulas in a worksheet, you may decide that using names in the
formulas will make it easier for others to analyze the worksheet. Since Excel does not
automatically replace cell references in existing formulas when you assign names, you
must replace the cell addresses in existing formulas with names as desired. This
technique is called applying names.

Names are applied to the current worksheet only. Consequently, you cannot group
worksheets and apply names to multiple sheets at the same time.

Vicon Learning System Page 27


Lesson 2 - Using Range Names Excel XP Level 4

Applying range names

ο If you want to apply names throughout a worksheet, you can


select a single cell in the worksheet.

ο Excel uses an underscore ( _ ) for blank spaces in a range


name. For example, the heading Total Sales will be assigned
the range name Total_Sales.

ξ Some names in the Apply Names dialog box may already be


selected. Be sure to deselect the names you do not want to
apply. Click once on a selected name to deselect it.

φ Step-by-Step
Apply range names to formulas.

If necessary, go to the Qtr 1 worksheet.

Page 28 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

Steps Practice Data


1. Select the range in which you want to Drag B8:G8
apply range names.
The range is selected.
2. Select the Insert menu. Click Insert
The Insert menu appears.
3. Point to the Name command. Point to Name
The Name submenu appears.
4. Select the Apply command. Click Apply...
The Apply Names dialog box opens,
and any suggested names are
highlighted in the Apply Names list
box.
5. Select the names you want to apply in Follow the instructions
the Apply names list box, if shown below the table
necessary. before continuing on to
The names are selected. the next step
6. Select OK. Click OK
The Apply Names dialog box closes,
and the names replace the cell
addresses in all formulas in the
selected range.

Select the following names in the Apply names list box.

Select Expenses, Feb, Jan, Mar, Net_Profits, and Total_Sales, if necessary.

Return to the table and continue on to the next step.

Select each cell in the range B8:G8. Notice that the cell addresses have been replaced
by names in each formula.

DELETING RANGE NAMES

δ Discussion
You can delete names you no longer use. For example, if you change the name of a
range, you can delete the old name.

Deleting a name permanently removes it from the workbook. If you accidentally


delete a name to which a formula refers, the formula can no longer calculate correctly;
the error message #NAME? appears in the cell instead of the result of the formula,
and the Error Checking button appears next to the cell containing the error message.

Vicon Learning System Page 29


Lesson 2 - Using Range Names Excel XP Level 4

ο If you inadvertently delete a name used in a formula, you can


redefine that name to make the formula accurate again.

ο You can click the Error Checking button for more


information about the error. The name of the error appears at
the top of the list and is highlighted in gray. Selecting the
Help on this error command opens the Microsoft Help
window to the pertinent error topic.

φ Step-by-Step
Delete a range name.

If necessary, go to the Qtr 1 worksheet.

Steps Practice Data


1. Select the Insert menu. Click Insert
The Insert menu appears.
2. Point to the Name command. Point to Name
The Name submenu appears.
3. Select the Define command. Click Define...
The Define Name dialog box opens.
4. Select the name you want to delete Click Net_Profits
from the Names in workbook list box.
The range name is selected.
5. Select Delete. Click Delete
The range name is deleted from the
workbook.
6. Select Close. Click Close
The Define Name dialog box closes.

Practice the Concept: Notice that the formula in cell G8 now displays an error
message, #NAME?, and the Error Checking button appears. Re-create the range
name Net_Profits for the range G4:G7. Notice that the formula updates.

Page 30 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

USING RANGE NAMES IN 3-D FORMULAS

δ Discussion
A 3-D formula is a formula where cell references refer to cells in more than one
worksheet. In standard 3-D formulas, you must activate each worksheet and select the
cells you want to reference as you are building the formula.

You can use range names as a simple and effective way to create 3-D formulas. Since
names are available to all worksheets in the workbook, you can select names from the
Name Box list or type them into the formula rather than going to each worksheet to
select cell references. This option can save you time and reduce confusion in creating
3-D formulas.

Names are often easier to remember than cell addresses, particularly in a large
worksheet or in multiple workbooks when you cannot see the desired cell.

When using names in formulas, you can either type the name into the formula or
select the name from the Paste Name dialog box. If range names are long, the Paste
Name dialog box helps you avoid typing errors.

Using range names in a 3-D formula

ο If you make a typing error or misspell a name, the #NAME?


error appears in the cell.

Vicon Learning System Page 31


Lesson 2 - Using Range Names Excel XP Level 4

φ Step-by-Step
Use range names in a 3-D formula.

Steps Practice Data


1. Select the worksheet in which you Click the Annual tab
want to create the formula.
The worksheet appears.
2. Select the cell in which you want to Click cell D3
create the formula.
The cell is selected.
3. Type = to start the formula. Type =
An equal sign (=) appears in the cell
and on the formula bar.
4. Press [F3]. Press [F3]
The Paste Name dialog box opens.
5. Double-click the desired name. Double-click
The name appears in the cell and on Qtr1_NetProfits
the formula bar.
6. Type the desired mathematical Type +
operator.
The mathematical operator appears.
7. Enter names and mathematical Follow the instructions
operators as necessary to complete the shown below the table
formula. before continuing on to
The formula appears on the formula the next step
bar.
8. Press [Enter]. Press [Enter]
The result of the formula appears in
the cell.

Press [F3] to open the Paste Names dialog box and double-click Qtr2_NetProfits to
insert the name. Continue creating the following formula by typing each operator and
using the Paste Name dialog box to insert each name:

=Qtr1_NetProfits+Qtr2_NetProfits+Qtr3_NetProfits+Qtr4_NetProfits

Return to the table and continue on to the next step.

The result of the formula should be $73,009.98.

Page 32 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

CREATING 3-D RANGE NAMES

δ Discussion
You can create names that refer to the same range in multiple worksheets. For
example, you can define a name for the same cell address in four different worksheets.
Naming a 3-D range can simplify creating a formula.

Creating a 3-D range name

ο Names that refer to 3-D ranges do not appear in the Name


Box. They do appear in the Paste Name dialog box.

φ Step-by-Step
Create a 3-D range name.

Steps Practice Data


1. Select the Insert menu. Click Insert
The Insert menu appears.
2. Point to the Name command. Point to Name
The Name submenu appears.
3. Select the Define command. Click Define...
The Define Name dialog box opens
with the insertion point in the Names
in workbook box.

Vicon Learning System Page 33


Lesson 2 - Using Range Names Excel XP Level 4

Steps Practice Data


4. Type the desired range name. Type All_Total
The range name appears in the Names
in workbook box.
5. Under Refers to, click the Collapse
Click
Dialog button.
The Define Name dialog box
collapses.
6. Go to the first worksheet of the group Click the Qtr 1 tab
you want to name.
The worksheet appears.
7. Hold [Shift] and click the tab of the Hold [Shift] and click the
last worksheet you want to include in Qtr 4 tab
the group.
The worksheets are grouped.
8. Select the range you want to name. Click cell E8
The range is selected.
9. Click the Expand Dialog button.
Click
The Define Name dialog box expands
and the 3-D range is selected.
10. Select Add. Click Add
The range name is added to the Names
in workbook list box.
11. Select OK. Click OK
The Define Name dialog box closes,
and the 3-D range named is created.

USING 3-D RANGE NAMES IN FORMULAS

δ Discussion
You can use a named 3-D range in a formula just as you would any other named
range. 3-D ranges can save you a significant amount of time. For example, if you have
named the cell containing the quarterly totals in each of four worksheets, you can sum
all four cells using the range name.

Page 34 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

Using a 3-D range name in a formula

φ Step-by-Step
Use a 3-D range name in a formula.

If necessary, display the Annual worksheet.

Steps Practice Data


1. Select the cell in which you want to Click cell B3
create the formula.
The cell is selected.
2. Type =, the function name, and an Type =sum(
open parenthesis ( ( ).
The beginning of the function appears
in the cell and on the formula bar.
3. Type the 3-D range name you want to Type All_Total
reference.
The range name appears in the cell
and on the formula bar.
4. Type any additional information Type )
needed to complete the function and
then type the closing parenthesis ( ) ).
The completed function appears in the
cell and on the formula bar.

Vicon Learning System Page 35


Lesson 2 - Using Range Names Excel XP Level 4

Steps Practice Data


5. Press [Enter]. Press [Enter]
The result of the formula appears in
the cell.

The result of the formula should be $94,613.98.


Close NAME1.XLS.

Page 36 Vicon Learning System


Excel XP Level 4 Lesson 2 - Using Range Names

EXERCISE
USING RANGE NAMES

ε Task
Create and use names for ranges.

1. Open Region14.
2. Select the range B4:D8 and create range names for each column
from the column headings.
3. Use the Name Box list to jump to the Mar range.
4. Delete the Jan, Feb, and Mar range names you just created.
5. On the Northeast worksheet, select the range B5:B8 and name it
Jan_NE.
6. Select the range C5:C8 and name it Feb_NE.
7. Select the range D5:D8 and name it Mar_NE.
8. Select cell B9 and create an =SUM formula using the Jan_NE
range.
9. Apply the range names to the formulas in the range C9:D9.
10. Use the Name Box list to jump to the Mar_C range. Notice that the
Central worksheet now appears on the screen.
11. Display the Totals worksheet.
12. Select cell D5 on the Totals worksheet. Create an =SUM formula
using the Mar_C, Mar_NE, and Mar_SE names to add the March
sales in each of the three worksheets. (Hint: Use commas to separate
the names in the SUM function: =SUM(Mar_C,Mar_NE,Mar_SE).)
13. Create a 3-D range name that includes cell E5 in each of the regional
worksheets (i.e., Northeast, Southeast, and Central). Name the
range Week1.
14. Create 3-D range names for cells E6, E7, and E8 in all the regional
worksheets. Name the ranges Week2, Week3, and Week4,
respectively.
15. Go to the By Week sheet, select cell B5, and create an =SUM
function that totals the 3-D range named Week1.

Vicon Learning System Page 37


Lesson 2 - Using Range Names Excel XP Level 4

16. Sum the other 3-D range names on the By Week worksheet. Sum
Week2 in cell B6, Week3 in cell B7, and Week4 in cell B8.
17. Close the workbook without saving it.

Page 38 Vicon Learning System


LESSON 3 -
USING ADVANCED FUNCTIONS

In this lesson, you will learn how to:


• Use lookup functions

• Use the VLOOKUP function

• Use the HLOOKUP function

• Use the IF function

• Use nested IF functions

• Use the ISERROR function

• Use an AND condition with IF

• Use an OR condition with IF

• Use the ROUND function

• Limit the precision of numbers


Lesson 3 - Using Advanced Functions Excel XP Level 4

USING LOOKUP FUNCTIONS

δ Discussion
Lookup functions look up values in a lookup table and return a result based on those
values. For example, if you need to look up the amount of a health insurance
deduction based on an employee’s salary and type of coverage, you can use a lookup
function to look up the salary and the type of coverage and return the amount of the
deduction.

Before you can use a lookup function, you must create the lookup table elsewhere in
the workbook and enter the desired data. This table must be sorted in ascending order.

There are two lookup functions: vertical and horizontal. The VLOOKUP function
expects the lookup value to be in the first column. The HLOOKUP function expects
the lookup value to be in the first row. The remaining arguments in the lookup
function specify the location of the table of information and the column in which to
find the matching value.

USING THE VLOOKUP FUNCTION

δ Discussion
The VLOOKUP function consists of three required arguments, in the following order:
lookup value, table array, and column index number. The lookup value is the value for
which you want to find matching data and must appear in the first column of the
lookup table; it can be a value, a text string, or a cell reference. The table array is the
name or address of the lookup table. The column index number is the number of
columns Excel must count over to find the matching value.

For example, you may have a parts table consisting of three columns, with the part
numbers in column one and the prices in column three. To look up the price for a
specified part number (lookup value), you would enter a column index value of 3;
Excel would then look for the lookup value in the first column of the parts table and
return the value in the third column of the same row.

You might want to use the lookup table shown below and a column index number of 2
to look up the percent of commission to be paid to a salesperson, based on various
sales levels. For example, if the sales figure you want to look up is 6000, the
commission would be 6%; Excel finds the lookup value (6000) in the first column and
returns the value in the second column of the same row.

Page 40 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

A B
1 SALES COMMISSION
2 1000 1%
3 2000 2%
4 3000 3%
5 4000 4%
6 5000 5%
7 6000 6%
8 7000 7%
9 8000 8%

The VLOOKUP function also has a optional fourth argument, range lookup, which
can be either TRUE or FALSE. If the range lookup argument is FALSE, VLOOKUP
will find only exact matches. If the range lookup argument is TRUE, or if a range
lookup argument is not entered, VLOOKUP can find approximate matches. In this
case, the lookup table must be sorted in ascending order by the first column in it;
otherwise VLOOKUP may not return the correct value.

If the range lookup argument is TRUE or omitted and the lookup value does not
appear in the first column of the lookup table, but falls between two values in it, Excel
will use the lower of the two values. If the lookup value is smaller than any value in
the first column of the lookup table, Excel returns an error message.

For example, using the lookup table shown above and a column index number of 2, if
the sales figure you look up is 5700, the commission would be 5%. Since Excel
determines that 5700 is located between the numbers 5000 and 6000, it returns the
value in the second column of the same row as the lower number.

Creating a VLOOKUP function

Vicon Learning System Page 41


Lesson 3 - Using Advanced Functions Excel XP Level 4

ο In order to copy a VLOOKUP function to other cells, its table


array argument must be an absolute reference. Since named
ranges are always absolute references, you can assign a name
to your lookup table and use that name in the VLOOKUP
function.

φ Step-by-Step
From the Student Data directory, open SALES72.XLS.
Use the VLOOKUP function.

If necessary, display the Orders worksheet.

Select prices from the Name Box (to the left of the formula bar) to view the lookup
table.

Steps Practice Data


1. Select the cell in which you want the Click cell C5
result of the VLOOKUP function to
appear.
The cell is selected.
2. Type =vlookup and an open Type =vlookup(
parenthesis ( ( ).
=vlookup( appears in the VLOOKUP
function.
3. Select the cell containing the value Click cell B5
you want to look up.
A blinking marquee appears around
the cell and its address appears in the
VLOOKUP function.
4. Type a comma ( , ). Type ,
The comma ( , ) appears in the
VLOOKUP function.
5. Type the name or address of the Type prices
lookup table.
The text appears in the VLOOKUP
function.
6. Type a comma ( , ). Type ,
The comma ( , ) appears in the
VLOOKUP function.

Page 42 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

Steps Practice Data


7. Enter the column index number. Type 2
The column index number appears in
the VLOOKUP function.
8. Type the closing parenthesis ( ) ). Type )
The closing parenthesis ( ) ) appears
in the VLOOKUP function.
9. Press [Enter]. Press [Enter]
The result of the VLOOKUP function
appears in the cell.

Notice that the returned price ($63.99) is the same as the price in the lookup table for
part ST-2472 (cell B21).

Copy the formula to the range C6:C13. Then, click anywhere in the worksheet to
deselect the range.

USING THE HLOOKUP FUNCTION

δ Discussion
The HLOOKUP function consists of three required arguments, in the following order:
lookup value, table array, and row index number. The lookup value is the value for
which you want to find matching data and must appear in the top row of the lookup
table; it can be a value, a text string, or a cell reference. The table array is the name or
address of the lookup table. The row index number is the number of rows Excel must
count down to find the matching value.

For example, you might have a lookup table consisting of two rows, with the total
order amount in the top row and the corresponding shipping charge in the second row.
To look up the shipping charge for a specified order amount (lookup value), you
would enter a row index value of 2; Excel would then look for the lookup value in the
top row of the lookup table and return the value in the second row of the same
column.

You might want to use the lookup table shown below and a row index number of 2 to
look up the percent of commission to be paid to a salesperson, based on various sales
levels. For example, if the sales figure you want to look up is 6000, the commission
would be 6%; Excel finds the lookup value (6000) in the top row and returns the value
in the second row of the same column.

A B C D E F G H
1 1000 2000 3000 4000 5000 6000 7000 8000
2 1% 2% 3% 4% 5% 6% 7% 8%

Vicon Learning System Page 43


Lesson 3 - Using Advanced Functions Excel XP Level 4

The HLOOKUP function also has a optional fourth argument, range lookup, which
can be either TRUE or FALSE. If the range lookup argument is FALSE, HLOOKUP
will find only exact matches. If the range lookup argument is TRUE, or if a range
lookup argument is not entered, HLOOKUP can find approximate matches. In this
case, the lookup table must be sorted in ascending order by its top row; otherwise
HLOOKUP may not return the correct value.

If the range lookup argument is TRUE or omitted and the lookup value does not
appear in the top row of the lookup table, but falls between two values in it, Excel
uses the lower of the two values. If the lookup value is smaller than any value in the
top row of the lookup table, Excel returns an error message.

For example, using the lookup table shown above and a row index number of 2, if the
sales figure you look up is 5700, the commission would be 5%. Since Excel
determines that 5700 is located between the numbers 5000 and 6000, it returns the
value in the second row of the same column as the lower number.

Creating an HLOOKUP function

ο In order to copy a HLOOKUP function to other cells, its table


array argument must be an absolute reference. Since named
ranges are always absolute references, you can assign a name
to your lookup table and use that name in the HLOOKUP
function.

ο You can use the Options button in the Sort dialog box to sort
a range by row.

Page 44 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

φ Step-by-Step
Use the HLOOKUP function.

If necessary, display the Orders worksheet.

Select shipping from the Name Box (to the left of the formula bar) to view the lookup
table.

Steps Practice Data


1. Select the cell in which you want the Click cell F5
result of the HLOOKUP function to
appear.
The cell is selected.
2. Type =hlookup and an open Type =hlookup(
parenthesis ( ( ).
=hlookup( appears in the HLOOKUP
function.
3. Select the cell containing the value Click cell E5
you want to look up.
A blinking marquee appears around
the cell and its address appears in the
HLOOKUP function.
4. Type a comma ( , ). Type ,
The comma ( , ) appears in the
HLOOKUP function.
5. Type the name or address of the Type shipping
lookup table.
The text appears in the VLOOKUP
function.
6. Type a comma ( , ). Type ,
The comma ( , ) appears in the
HLOOKUP function.
7. Enter the row index number. Type 2
The row index number appears in the
HLOOKUP function.
8. Type a closing parenthesis ( ) ). Type )
The closing parenthesis ( ) ) appears
in the HLOOKUP function.
9. Press [Enter]. Press [Enter]
The result of the HLOOKUP function
appears in the cell.

Vicon Learning System Page 45


Lesson 3 - Using Advanced Functions Excel XP Level 4

Notice that since the lookup value ($639.90) is between two values in the lookup
table, the returned cost ($50.00) is the same as the cost for the lower amount ($400),
in cell G18.

Copy the formula to the range F6:F13. Click anywhere in the worksheet to deselect
the range.

USING THE IF FUNCTION

δ Discussion
Logical functions make decisions based on criteria. If the criteria evaluate to true, one
action is taken; if the criteria evaluate to false, a different action is taken.

This decision-making capability of logical functions can be applied to many different


situations. You can use a logical function to decide if a customer receives a discount
for goods ordered. If an ordered value is greater than the specified amount, the
customer receives a discount. If an ordered value is less than the specified amount, the
customer does not receive a discount.

The IF function returns one value if a condition is true and another value if a condition
is false. In the example above, if the value of the goods shipped is greater than the
specified amount, a true value would be returned. If the shipped value is less than the
specified amount, a false value would be returned.

You can also use the IF function to display text as a result of a logical test, but you
must enclose the text you want to display in quotation marks.

The syntax of an IF function is:

=IF(logical test,value if true,value if false)

The function arguments are described in the following table:

Component Description
logical test The test condition. It can contain cell references, text in
quotes, cell names, and numbers. The items are
compared using the following comparison operators:
= equal to
<> not equal to
> greater than
>= greater than or equal to
< less than
<= less than or equal to

Page 46 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

Component Description
value if true The desired result if the logical test is true. It can be a
number, formula, cell reference, cell name, text in
quotes, or another function.
value if false The desired result if the logical test is false. It can be a
number, formula, cell reference, cell name, text in
quotes, or another function.

Some examples of the IF function are listed in the following table:

IF Function Result
=IF(B7>10,C7*.1,0) If the number in cell B7 is greater
than 10, multiply the number in cell
C7 by .1; otherwise, return the
number 0
=IF(B7<=10,C7*.1,D7*.1) If the number in cell B7 is less than
or equal to 10, multiply the number
in cell C7 by .1; otherwise, multiply
the number in cell D7 by .1
=IF(B7<>10,"GOOD","") If the number in cell B7 is not equal
to 10, enter the text GOOD in the
current cell; otherwise, leave the cell
blank
=IF(B7="BONUS",C7+1000,C7) If cell B7 contains the text BONUS,
add 1000 to the number in cell C7;
otherwise, enter the contents of cell
C7

Vicon Learning System Page 47


Lesson 3 - Using Advanced Functions Excel XP Level 4

Creating an IF function

φ Step-by-Step
Use the IF function.

Display the Bonus worksheet.

Steps Practice Data


1. Select the cell in which you want the Click cell G8
result of the IF function to appear.
The cell is selected.
2. Type =if and an open parenthesis ( ( ). Type =if(
=if( appears in the cell and on the
formula bar.
3. Type the logical test. Type e8>f8
The text appears in the cell and on the
formula bar.
4. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
5. Type the action to be taken if the Type e8*10%
logical test is true.
The text appears in the cell and on the
formula bar.

Page 48 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

Steps Practice Data


6. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
7. Type the action to be taken if the Type 0
logical test is false.
The text appears in the cell and on the
formula bar.
8. Type the closing parenthesis ( ) ) . Type )
The closing parenthesis ( ) ) appears
in the cell and on the formula bar.
9. Press [Enter]. Press [Enter]
The result of the IF function appears
in the cell.

Notice that since the first quarter sales total for Smith, S. was below his quota, a zero
(0) was entered as his bonus.

Copy the formula to the range G9:G13. Then, click anywhere in the worksheet to
deselect the range.

USING NESTED IF FUNCTIONS

δ Discussion
You can use an IF function within another IF function to create a nested IF function.
A nested IF function allows you to test for a second condition if the first condition is
found false. For example, an IF function could test whether or not a number is equal
to 1. If false, another IF function within the first could test whether or not the number
is equal to 2.

The syntax of a nested IF function is:

=IF(logical test,value if true,IF(logical test,value if true,value if false))

You can create up to seven nested IF functions within an IF function.

Vicon Learning System Page 49


Lesson 3 - Using Advanced Functions Excel XP Level 4

Creating a nested IF function

ξ You must close all parentheses in a nested IF function; i.e., the


number of open parentheses must equal the number of closing
parentheses.

φ Step-by-Step
Use nested IF functions.

If necessary, display the Bonus worksheet.

Steps Practice Data


1. Select the cell in which you want the Click cell J8
result of the nested IF function to
appear.
The cell is selected.
2. Type =if and an open parenthesis ( ( ). Type =if(
=if( appears in the cell and on the
formula bar.
3. Type the first logical test. Type i8=1
The text appears in the cell and on the
formula bar.

Page 50 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

Steps Practice Data


4. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
5. Type the action to be taken if the first Type h8*10%
logical test is true.
The text appears in the cell and on the
formula bar.
6. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
7. Type if and an open parenthesis ( ( ). Type if(
If( appears in the cell and on the
formula bar.
8. Type the logical test for the second IF Type i8=2
function.
The text appears in the cell and on the
formula bar.
9. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
10. Type the action to be taken if the Type h8*8%
logical test for the second IF function
is true.
The text appears in the cell and on the
formula bar.
11. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
12. Type the action to be taken if the Type h8*7%
second logical test is false.
The text appears in the cell and on the
formula bar.
13. Type two closing parentheses ( )) ). Type ))
The closing parentheses ( )) ) appear
in the cell and on the formula bar.
14. Press [Enter]. Press [Enter]
The result of the nested IF function
appears in the cell.

Copy the formula to the range J9:J13. Then, click anywhere in the worksheet to
deselect the range.

Vicon Learning System Page 51


Lesson 3 - Using Advanced Functions Excel XP Level 4

USING THE ISERROR FUNCTION

δ Discussion
Depending upon the circumstances, a function may return an error message instead of
performing the desired calculation. For instance, a function that averages a range will
return a #DIV/0! error message if the range contains no data. The ISERROR function
is commonly used within an IF function to handle errors messages returned by a
formula.

The ISERROR function tests TRUE if any of the following error messages are
returned by a formula: #N/A, #VALUE, #REF, #DIV/0!, #NUM, #NAME?, or
#NULL. It tests FALSE if anything other than an error message is returned.

The ISERR function is similar to the ISERROR function, except that it does not
respond to the error value #N/A.

The syntax of these functions is as follows, where (value) is a cell reference or range
name:

ISERROR(value)
ISERR(value)

Using the ISERROR function

Page 52 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

ο If you are unsure of the contents of one or more cells on which


the calculations are being made, you can use the ISERROR
function because it provides a result regardless of the error
condition.

φ Step-by-Step
Use the ISERROR function in an IF function.

Display the Quota worksheet.

Steps Practice Data


1. Select the cell in which you want the Click cell F15
result of the IF function to appear.
The cell is selected.
2. Type =if and an open parenthesis ( ( ). Type =if(
=if( appears in the cell and on the
formula bar.
3. Type the ISERROR function as the Type iserror(average
logical test. (f8:f13))
The text appears in the cell and on the
formula bar.
4. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
5. Type the action to be taken if the Type "no data"
ISERROR function is true.
The text appears in the cell and on the
formula bar.
6. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
7. Type the action to be taken if the Type average (f8:f13)
ISERROR function is false.
The text appears in the cell and on the
formula bar.
8. Type the closing parenthesis ( ) ). Type )
The closing parenthesis ( ) ) appears
in the cell and on the formula bar.

Vicon Learning System Page 53


Lesson 3 - Using Advanced Functions Excel XP Level 4

Steps Practice Data


9. Press [Enter]. Press [Enter]
The result of the ISERROR function
appears in the cell.

The formula returns the text no data instead of the error message. Copy the formula
to the range G15:I15. Then, type 50,000 in cell F8 and press [Enter]; notice that the
message in cell F15 changes.

USING AN AND CONDITION WITH IF

δ Discussion
You can use AND conditions to test multiple criteria in IF functions. For example,
you may want to give a salesperson a $500 bonus if he or she produces $10,000 in
sales and has at least five years experience. This example represents an AND
condition. When used in an IF function, an AND condition returns a TRUE value if
both arguments are true and a FALSE value if either argument is false.

The syntax of an AND condition is:

=IF(AND(logical test1,logical test2),value if true,value if false)

Creating an AND condition in an IF function

Page 54 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

φ Step-by-Step
Use an AND condition in an IF function.

Display the Raises worksheet.

Steps Practice Data


1. Select the cell in which you want the Click cell D8
result of the IF function to appear.
The cell is selected.
2. Type =if and an open parenthesis ( ( ). Type =if(
=if( appears in the cell and on the
formula bar.
3. Type the AND condition. Type and(b8>0,c8>1)
The text appears in the cell and on the
formula bar.
4. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
5. Type the action to be taken if both Type "Yes"
conditions are true.
The text appears in the cell and on the
formula bar.
6. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
7. Type the action to be taken if either Type "No"
condition is false.
The text appears in the cell and on the
formula bar.
8. Type a closing parenthesis ( ) ). Type )
The closing parenthesis ( ) ) appears
in the cell and on the formula bar.
9. Press [Enter]. Press [Enter]
The result of the IF function appears
in the cell.

The correct answer is No, since only one condition is true.

Copy the formula to the range D9:D13. Then, click anywhere in the worksheet to
deselect the range.

Vicon Learning System Page 55


Lesson 3 - Using Advanced Functions Excel XP Level 4

USING AN OR CONDITION WITH IF

δ Discussion
You can use OR conditions to test multiple criteria in IF functions. For example, you
may want to give a salesperson a $500 bonus if he or she produces $10,000 in sales or
if he or she has at least five years experience. This example represents an OR
condition. When used in an IF function, the OR condition returns a TRUE value if
either argument is true and a FALSE value if both arguments are false.

The syntax of an OR condition is:

=IF(OR(logical test1,logical test2),value if true,value if false)

Creating an OR condition in an IF function

φ Step-by-Step
Use an OR condition in an IF function.

If necessary, display the Raises worksheet.

Page 56 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

Steps Practice Data


1. Select the cell in which you want the Click cell E8
result of the IF function to appear.
The cell is selected.
2. Type =if and an open parenthesis ( ( ). Type =if(
=if( appears in the cell and on the
formula bar.
3. Type the OR condition. Type or(b8>10000,c8=3)
The text appears in the cell and on the
formula bar.
4. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
5. Type the action to be taken if either of Type "Yes"
the conditions is true.
The text appears in the cell and on the
formula bar.
6. Type a comma ( , ). Type ,
The comma ( , ) appears in the cell
and on the formula bar.
7. Type the action to be taken if both Type "No"
conditions are false.
The text appears in the cell and on the
formula bar.
8. Type the closing parenthesis ( ) ). Type )
The closing parenthesis ( ) ) appears
in the cell and on the formula bar.
9. Press [Enter]. Press [Enter]
The result of the IF function with the
OR condition appears in the cell.

Copy the formula to the range E9:E13. Then, click anywhere in the worksheet to
deselect the range.

USING THE ROUND FUNCTION

δ Discussion
When you enter a number into an Excel worksheet, Excel can store it with up to 15
digits. Although you can format numbers so that Excel rounds off extra decimal

Vicon Learning System Page 57


Lesson 3 - Using Advanced Functions Excel XP Level 4

places, Excel uses all decimal places in calculations. This feature can lead to some
calculations appearing incorrect.

Rounding a number is different than formatting a number. When you round a number
to a certain number of decimal places, the extra decimal places are removed and all
calculations are performed using the rounded value.

The ROUND function includes the following two arguments:

ROUND(number,number of digits)

The number argument can be a value or a cell address. The number of digits argument
determines the precision of the rounded number. A positive number of digits argument
returns an equal number of decimal places. If the number of digits argument is 0,
Excel rounds to the next whole number. A negative number of digits argument rounds
exponentially to the next ten, hundred, thousand, etc.

Some examples of the ROUND function are listed in the following table:

ROUND function Cell displays


=ROUND(4567.4567,1) 4567.5 (one decimal place)
=ROUND(4567.4567,2) 4567.46 (two decimal places)
=ROUND(4567.4567,0) 4567 (no decimal places)
=ROUND(4567.4567,-1) 4570 (rounds to the nearest ten)
=ROUND(B7,2) The value in cell B7 rounded to two decimal
places
=ROUND(B7*.1,2) The result of the number in cell B7 times .1,
rounded to two decimal places

Page 58 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

Creating a ROUND function

φ Step-by-Step
Use the ROUND function.

Display the Invest worksheet.

Steps Practice Data


1. Select the cell in which you want the Click cell F7
result of the ROUND function to
appear.
The cell is selected.
2. Type =round and an open parenthesis Type =round(
( ( ).
=round( appears in the cell and on the
formula bar.
3. Type the value, formula, cell address, Type d7,
or function you want to round,
followed by a comma.
The text appears in the cell and on the
formula bar.
4. Type the desired number of decimal Type 4
places.
The text appears in the cell and on the
formula bar.

Vicon Learning System Page 59


Lesson 3 - Using Advanced Functions Excel XP Level 4

Steps Practice Data


5. Type the closing parenthesis ( ) ). Type )
The closing parenthesis ( ) ) appears
in the cell and on the formula bar.
6. Press [Enter]. Press [Enter]
The result of the ROUND function
appears in the cell.

Notice that the number in cell G7 differs from that in cell E7 because it is based on the
rounded number in cell F7. Then, copy the formula to the range F8:F12.

Select the range D7:D12 and click the Decrease Decimal button on the Formatting
toolbar twice to format the numbers for four decimal places. Notice that the values in
column E do not change; the calculations are still based on the full number of decimal
places. Use the Undo feature twice to remove the formatting.

LIMITING THE PRECISION OF NUMBERS

δ Discussion
In order to calculate a worksheet using the numbers as they are displayed, you can
limit the precision of formatted numbers. Limiting the precision changes the actual
values in the worksheet to their formatted versions. For example, if a cell containing
an actual value of 123.4567 is formatted with no decimal places, only 123 will
display. In a calculation, however, Excel will still use 123.4567 (the entire number,
including all decimal places). If you limit the precision of the cell to the formatted
value, Excel will use only the formatted value (123) in calculations and will actually
remove all decimal places in the stored number.

Page 60 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

Limiting the precision of numbers

ξ Be careful when limiting the precision of numbers because


you cannot undo it. You can, however, restore your original
numbers if you immediately exit the worksheet without saving
the changes.

φ Step-by-Step
Limit the precision of numbers.

If necessary, display the Invest worksheet.

Select cell C7. Notice that, although the salary displayed on the worksheet is 4975, the
actual value in the cell is 4974.554. All the salaries in column C have three or more
decimal places, even though the decimal places do not appear due to the cell
formatting.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Select the Options command. Click Options...
The Options dialog box opens.
3. Select the Calculation tab. Click the Calculation tab
The Calculation page appears.

Vicon Learning System Page 61


Lesson 3 - Using Advanced Functions Excel XP Level 4

Steps Practice Data


4. Select the Precision as displayed Click Precision as
option. displayed
The Precision as displayed option is
selected.
5. Select OK. Click OK
The Options dialog box closes, and a
Microsoft Excel warning box opens to
inform you that the data will
permanently lose accuracy.
6. Select OK. Click OK
The Microsoft Excel warning box
closes, and the numbers in the
worksheet are recalculated using
limited precision.

Select each of the cells in column C, one at a time. Notice that the decimal places have
been removed.
Close SALES72.XLS.

Page 62 Vicon Learning System


Excel XP Level 4 Lesson 3 - Using Advanced Functions

EXERCISE
USING ADVANCED FUNCTIONS

ε Task
Use advanced functions in a workbook.

1. Open Functex.
2. Display the Hours worksheet, if necessary.
3. Select cell F6 and use the VLOOKUP function to calculate the pay
rate for full-time, part-time, or overtime work, according to job type.
(Hint: The lookup value is the Job Type in C6, the lookup table is
named table, and the column index number is the Type of Time in
E6.)
4. Copy the formula to the range F7:F12.
5. Display the Sales-Previous worksheet.
6. Customers get free shipping if their average sales are more than
20,000. In cell I5, use an IF function to test the average sales. If the
average sales (H5) are greater than or equal to 20,000, Yes should
appear in the cell; otherwise, No should appear in the cell. (Hint: Do
not add a comma in 20000.)
7. Copy the formula to the range I6:I13.
8. The customer discount depends on the customer status. In cell J5, use
a nested IF function to determine the correct discount for each
customer according to the following table. (Hint: Test to see if the
status in cell B5 is a 1, 2, or 3; otherwise, a discount of 10% is
entered.)

Status Discount
1 0%
2 5%
3 7.5%
4 10%

Vicon Learning System Page 63


Lesson 3 - Using Advanced Functions Excel XP Level 4

9. Copy the formula to the range J6:J13.


10. A customer status of 2 or 4 indicates a long-standing, good credit
history and the customer credit limit should be raised by 5%; all
other credit limits will remain the same. In cell K5, use an OR
condition in an IF function to display which customers should have
their credit limits raised. Display 5% or 0% in the cells accordingly.
11. Copy the formula in cell K5 to K6:K13.

12. Display the Sales-Current worksheet.


13. In cell C16, use an ISERROR function in an IF function to change
the #DIV/0! message to No data. Copy the formula to the range
D16:F16.
14. Display the Commissions worksheet.
15. Use the ROUND function to round the results of the commission
formula in cell C5 to two decimal places. (Hint: Modify the existing
formula in C5.) Then, copy the formula to the range C6:C13.
16. Format the numbers in the range B5:B13 so that no decimal places
appear.
17. Limit the precision of numbers. Notice that the values in C5:C13
change accordingly.
18. Close the workbook without saving it.

Page 64 Vicon Learning System


LESSON 4 -
USING DATA TABLES

In this lesson, you will learn how to:


• Use data tables

• Place formulas in data tables

• Create a one-variable table

• Create a two-variable table


Lesson 4 - Using Data Tables Excel XP Level 4

USING DATA TABLES

δ Discussion
You can use a data table to vary one or two values in a formula and display all
possible results in a table format. For example, you can use a data table to display all
possible projected sales based on total sales and various growth percentages.

To create a data table, you must first indicate the input cells (the cells containing the
variable values in the formula). In the previous sales growth example, the input cells
are the cells containing the total sales and those containing the percentage growth
figures. The input values are then substituted in the formula and the result of each
calculation is placed into an output cell in the data table.

PLACING FORMULAS IN DATA TABLES

δ Discussion
When you create a data table, the placement of the formula used in the calculation
varies, depending on the type of data table you are creating.

If a one-variable data table is arranged in columns, the formula used in the calculation
is placed in the cell at the top of the output column. In the following diagram, column
B is the output column and the formula must be placed in cell B1.

A B
1 FORMULA
2 25.67
3 12.50
4 35.42
5 97.16
A one-variable data table arranged in columns

If a one-variable data table is arranged in rows, the formula is placed in the cell to the
left of the output row. In the following diagram, row 2 is the output row and the
formula must be placed in cell A2.

A B C D E
1 25.67 12.50 35.42 97.16
2 FORMULA
A one-variable data table arranged in rows

Page 66 Vicon Learning System


Excel XP Level 4 Lesson 4 - Using Data Tables

In a two-variable data table, both rows and column are used for input data, and the
formula used in the calculations must be placed above the column input cells and to
the left of the row input cells. In the following diagram, column A contains one set of
variable input values and row 1 contains the other set of input values. Therefore, the
formula must be placed in cell A1.

A B C D E
1 FORMULA 25.67 12.50 35.42 97.16
2 5
3 10
4 15
5 20
A two-variable data table

CREATING A ONE-VARIABLE TABLE

δ Discussion
When you create a one-variable data table, you can enter the input values either across
a row or down a column.

If the one-variable data table consists of two columns, the first column is the input
column and contains all possible values for the variable. The second column is the
output column. In addition, the cell directly above the output column must contain the
formula used in calculating the data table.

If the one-variable data table consists of two rows, the top row is the input row, the
second row is the output row, and the cell to the left of the output row must contain
the formula.

The input cell is critical when creating a data table. It is the cell containing the
variable value and must be included in the formula. As the variable values are entered
into the data table, the result of each calculation appears in the corresponding cell in
the output column.

Vicon Learning System Page 67


Lesson 4 - Using Data Tables Excel XP Level 4

A one-variable data table

φ Step-by-Step
From the Student Data directory, open WHATIF1.XLS.
Create a one-variable data table.

If necessary, display the One Variable worksheet.

Steps Practice Data


1. Select the cell immediately above the Click cell B5
output column.
The cell is selected.
2. Type the formula you want to Type =a2*b2
evaluate.
The text appears in the cell and on the
formula bar.
3. Press [Enter]. Press [Enter]
The result of the formula appears in
the cell.
4. Select the entire range containing the Drag A5:B16
formula, the input column, and the
output column.
The range is selected.

Page 68 Vicon Learning System


Excel XP Level 4 Lesson 4 - Using Data Tables

Steps Practice Data


5. Select the Data menu. Click Data
The Data menu appears.
6. Select the Table command. Click Table...
The Table dialog box opens with the
insertion point in the Row input cell
box.
7. Select the Column input cell box. Click in the Column
The insertion point appears in the input cell box
Column input cell box.
8. Select the input cell. Click cell B2
The cell is selected and appears in the
Column input cell box.
9. Select OK. Click OK
The Table dialog box closes, and the
data table appears in the selected
range.

Practice the Concept: Select cell A2, type 159.99, and press [Enter]. Notice that the
data table recalculates.

CREATING A TWO-VARIABLE TABLE

δ Discussion
You can create a two-variable data table that evaluates two different values in a
formula. A two-variable data table uses both an input column and an input row. The
input row is the first row and the input column is the first column in the data table.
You enter the formula you want to calculate in the cell above the input column and to
the left of the input row.

A two-variable data table references two input cells: one for column input data and
one for row input data; both input cells must be included in the formula. The formula
calculates each of the possible combinations of the row and column input cells and
places the results in the corresponding, intersecting cell in the data table.

Vicon Learning System Page 69


Lesson 4 - Using Data Tables Excel XP Level 4

Creating a two-variable data table

φ Step-by-Step
Create a two-variable data table.

Display the Two Variables worksheet. Notice that the unit prices of several items are
listed across row 5 and that a list of increasing quantities appears down column A.

Steps Practice Data


1. Select the cell above the column input Click cell A5
values and to the left of the row input
values.
The cell is selected.
2. Type the formula you want to Type =a2*b2
evaluate.
The text appears in the cell and on the
formula bar.
3. Press [Enter]. Press [Enter]
The result of the formula appears in
the cell.
4. Select the entire data table. Drag A5:H16
The range is selected.
5. Select the Data menu. Click Data
The Data menu appears.

Page 70 Vicon Learning System


Excel XP Level 4 Lesson 4 - Using Data Tables

Steps Practice Data


6. Select the Table command. Click Table...
The Table dialog box opens with the
insertion point in the Row input cell
box.
7. Select the row input cell. Click cell A2
The cell is selected and appears in the
Row input cell box.
8. Select the Column input cell box. Press [Tab]
The insertion point appears in the
Column input cell box.
9. Select the column input cell. Click cell B2
The cell is selected and appears in the
Column input cell box.
10. Select OK. Click OK
The Table dialog box closes, and the
two-variable data table is created.

Practice the Concept: In cell D5, type 85.12 and press [Enter]. (Adjust the column
width, if necessary, to view the values.) Notice that Excel recalculates all the values in
column D, based on the new input value.
Close WHATIF1.XLS.

Vicon Learning System Page 71


Lesson 4 - Using Data Tables Excel XP Level 4

EXERCISE
USING DATA TABLES

ε Task
Create one-variable and two-variable data tables.

1. Open Commrate.
2. In cell B5, enter a formula to multiply the Unit Price value in cell
A2 by the Quantity value in cell B2.
3. Create a one-variable data table in the range B4:G5. (Hint: The row
input cell is the quantity in cell B2.)
4. In cell A11, enter a formula that multiplies the sales figure in cell A8
by the commission rate in cell B8.
5. Create a two-variable data table in the range A11:G16. (Hint: The
row input cell is cell B8 and the column input cell is cell A8.)
6. Close the workbook without saving it.

Page 72 Vicon Learning System


LESSON 5 -
USING MACROS

In this lesson, you will learn how to:


• Define macros

• Open a workbook containing macros

• Run a macro

• Use a shortcut key

• Use the Visual Basic toolbar

• Open the Visual Basic Editor window

• Use the Visual Basic Editor window


Lesson 5 - Using Macros Excel XP Level 4

DEFINING MACROS

δ Discussion
A macro is a program you can create to automatically perform frequently used
operations. It contains all the commands, mouse movements, and user actions
necessary to complete a task. Macros can save you considerable time because you can
use them to automate repetitive, time-consuming tasks. You can use macros for
simple tasks you perform frequently or for complex tasks that require consistency.

Excel macros are written in the Visual Basic for Applications programming language.
The series of commands used in a macro is known as a procedure. Each procedure is
given a name that is used to execute the macro.

Each procedure is saved in a device called a module. This module is attached to the
worksheet in which the macro is stored. A module is hidden and cannot be seen in the
normal window view. You must use the Visual Basic Editor to select a module in
order to view and edit the macro commands.

All procedures begin with the word Sub, followed by the name of the macro and an
open and a closing parenthesis, and end with the words End Sub. Commands entered
between these two lines are macro statements. When you record a procedure, Visual
Basic translates the menu choices and keystrokes into the macro statements.
Comments may also be inserted into a procedure to add clarity. If you know Visual
Basic, you can write a procedure yourself instead of using the macro recorder.

ο A macro can be stored in a specific workbook or the Personal


Macro Workbook. Macros stored in a specific workbook can
only be used when that workbook is open. The Personal
Macro Workbook automatically opens when you start Excel.
As a result, macros stored in the Personal Macro Workbook
are available to all files.

OPENING A WORKBOOK CONTAINING MACROS

δ Discussion
When you open a workbook containing macros, you could unknowingly install a virus
on your computer. A virus is a type of macro that is self-activated when a workbook is
opened. It can invade your computer and be stored in hidden fashion in one or all of

Page 74 Vicon Learning System


Excel XP Level 4 Lesson 5 - Using Macros

your worksheets. Therefore, it is very beneficial to have the ability to enable or


disable macros as you open a workbook.

Excel provides protection against such incidents. A Microsoft Excel warning box
opens if a workbook containing macros is opened. This warning box gives you a
number of choices. If you can verify the source of the macros, you can enable them
and open the workbook without risking exposure to a virus. If you are not sure of the
source of the macros, you can disable the macros before you open the workbook and
then verify the macros later.

You can choose how you want Excel to respond to macros on the Security Level page
in the Security dialog box, which is accessed from the Security page in the Options
dialog box. A High security setting is the default and will only enable macros from a
list of trusted sources. If you select a Low security setting, workbooks containing
macros will open without a prompt. A Medium security setting will prompt you to
enable or disable the macros.

Opening a workbook containing macros

ο The More Info button in the Microsoft Excel message box


accesses Excel Help.

ξ In order for this topic to work properly, macro security must


be set to Medium on the Security Level page in the Security
dialog box. To open this dialog box, select the Tools menu,
the Options command, the Security tab, and the Macro
Security button. Then, select the Medium option and OK
twice.

φ Step-by-Step
Open a workbook containing macros.

Vicon Learning System Page 75


Lesson 5 - Using Macros Excel XP Level 4

Steps Practice Data


1. Click the Open button on the
Standard toolbar. Click
The Open dialog box opens.
2. Select the Look in list. Click Look in
A list of available drives appears.
3. Select the drive where the macro Click the student data
workbook you want to open is stored. drive
A list of available folders appears.
4. Open the folder where the macro Double-click the student
workbook you want to open is stored. data folder
A list of available folders and files
appears.
5. Select the macro workbook you want Click City56
to open.
The file name is selected.
6. Select Open. Click Open
The Open dialog box closes, and a
Microsoft Excel message box opens to
prompt you to disable or enable
macros.
7. Select Enable Macros. Click Enable Macros
The Microsoft Excel message box
closes, the workbook opens, and the
macros are enabled.

RUNNING A MACRO

δ Discussion
Macros are saved in modules, and both are saved with the workbook in which they
were written. Before you can run a macro, the workbook in which it is saved must be
open. When you select a macro from the Macro dialog box, Excel performs its
commands in sequence.

Macros in any open workbook can be run from any other open workbook.

Page 76 Vicon Learning System


Excel XP Level 4 Lesson 5 - Using Macros

Running a macro

ο You can also run macros by clicking the Run Macro button
on the Visual Basic toolbar.

ξ In order for this topic to work properly, macro security must


be set to Medium on the Security Level page in the Security
dialog box. To open this dialog box, select the Tools menu,
the Options command, the Security tab, and the Macro
Security button. Then, select the Medium option and OK
twice.

φ Step-by-Step
Run a macro.

If necessary, enable the macros.

The macro used in the following step-by-step does not contain a file path. As a result,
it will look in the folder that contains the City56.xls data file. Make sure that your
current folder is set for the path containing the student data files.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.

Vicon Learning System Page 77


Lesson 5 - Using Macros Excel XP Level 4

Steps Practice Data


2. Point to the Macro command. Point to Macro
The Macro submenu appears.
3. Select the Macros command. Click Macros...
The Macro dialog box opens.
4. Select the macro you want to run. Click NewYork
The macro is selected.
5. Select Run. Click Run
The Macro dialog box closes, and the
macro runs.

Close the Newyork workbook.

USING A SHORTCUT KEY

δ Discussion
Excel performs macro commands in sequence. If a macro has a shortcut key assigned
to it, you can run the macro by pressing the shortcut key. A shortcut key consists of
pressing the [Ctrl] key and a key assigned to the macro. If an uppercase letter has
been assigned, you need to press the [Ctrl] key, the [Shift] key, and the letter
assigned to the macro.

ο The workbook containing the macro must be open.

ξ Macro shortcut keys are case-sensitive. If the shortcut key is


the [Ctrl] key plus the uppercase letter N, you must press
[Ctrl+Shift+N] or the macro will not run.

ξ In order for this topic to work properly, macro security must


be set to Medium on the Security Level page in the Security
dialog box. To open this dialog box, select the Tools menu,
the Options command, the Security tab, and the Macro
Security button. Then, select the Medium option and OK
twice.

Page 78 Vicon Learning System


Excel XP Level 4 Lesson 5 - Using Macros

φ Step-by-Step
Use a shortcut key to run a macro.

If necessary, enable the macros.

The shortcut key for this macro is the lowercase letter n.

The macro used in the following step-by-step does not contain a file path. As a result,
it will look in the folder that contains the City56.xls data file. Make sure that your
current folder is set for the path containing the student data files.

Steps Practice Data


1. Press the shortcut key assigned to the Hold [Ctrl] and press n
macro.
The macro runs.

Close the Newyork workbook.

USING THE VISUAL BASIC TOOLBAR

δ Discussion
The Visual Basic toolbar provides a variety of buttons that can be used when creating,
editing, or running macros.

The Run Macro button opens the Macro dialog box, so that you can run a macro. The
Record Macro button allows you to record a macro. The Visual Basic Editor button
opens the Visual Basic Editor window, in which you can edit an existing macro.

Since macros can transmit viruses, you can use the Security button to set the security
level you want to employ when opening workbooks containing macros.

Other buttons are used for automating forms and working with HTML tags and scripts
for workbooks saved as Web pages.

The Visual Basic toolbar

Vicon Learning System Page 79


Lesson 5 - Using Macros Excel XP Level 4

ξ In order for this topic to work properly, macro security must


be set to Medium on the Security Level page in the Security
dialog box. To open this dialog box, select the Tools menu,
the Options command, the Security tab, and the Macro
Security button. Then, select the Medium option and OK
twice.

φ Step-by-Step
Use the Visual Basic toolbar.

Make sure that your current folder is set for the path containing the student data files.

Steps Practice Data


1. Right-click any toolbar. Right-click any toolbar
The toolbar shortcut menu appears.
2. Select the Visual Basic command. Click Visual Basic
The Visual Basic toolbar opens.
3. Click the desired button.
The corresponding action takes place. Click

Run the Atlanta macro and then close the Atlanta workbook.

OPENING THE VISUAL BASIC EDITOR WINDOW

δ Discussion
Excel macros are written in the Visual Basic for Applications (VBA) programming
language. Macros are saved in modules, which in turn are saved in the worksheet in
which the macros were written. Modules cannot be viewed in the normal window
view; they can only be displayed in the Visual Basic Editor window. You can view,
edit, and run macros from this window.

The Visual Basic Editor window houses three smaller windows. The upper left
window is the Project Explorer window. It displays the various worksheets and
modules in folder and file format. These folders, worksheets, and modules can be
displayed or hidden in much the same way as files and folders are displayed or hidden
in Windows Explorer.

The lower left window is the Properties window. It displays the properties of the
worksheet or module selected in the Project Explorer window.

Page 80 Vicon Learning System


Excel XP Level 4 Lesson 5 - Using Macros

The large window at the right is the Code window. It displays the contents of the
worksheet or module selected in the Project Explorer window. For example, when a
module is selected, the entire procedure, including the header, footer, macro name,
macro code, and comments, appears in the Code window. You use the Code window
to display, edit, and run macros.

The Visual Basic Editor window

ο If the Project Explorer window or the Properties window is


not open in the Visual Basic Editor window, you can click the
Project Explorer or Properties Window button on the
Standard toolbar in the Visual Basic Editor window to open
them.

ο To open the Code window, select the View menu and the
Code command.

ο The Visual Basic Editor window can also be opened by


pressing the [Alt+F11] key combination or by selecting the
Tools menu, the Macro command, and the Visual Basic
Editor command. You can also press the [Alt+F11] key
combination to toggle between Excel and the Visual Basic
Editor.

Vicon Learning System Page 81


Lesson 5 - Using Macros Excel XP Level 4

φ Step-by-Step
Open the Visual Basic Editor window.

If necessary, enable the macros and display the Visual Basic toolbar.

Steps Practice Data


1. Click the Visual Basic Editor button
on the Visual Basic toolbar. Click
The Visual Basic Editor window
opens.

Practice the Concept: If necessary, maximize the Code window. Press [Alt+F11] to
switch to the Excel window. Then, display the Visual Basic Editor window again.

USING THE VISUAL BASIC EDITOR WINDOW

δ Discussion
The Visual Basic Editor window displays the Project Explorer window, the Properties
window, and the Code window. Each of these windows can be opened and closed
independently. When a closed window is reopened, it opens in its previous size and
location.

ο You can also press the [Ctrl+R] key combination to open the
Project Explorer window, the [F4] key to open the Properties
window, and the [F7] key to open the Code window.

φ Step-by-Step
Use the Visual Basic Editor window.

If necessary, enable the macros and open the Visual Basic Editor window.

Steps Practice Data


1. Close the Project Explorer window. Click on the Project
The Project Explorer window closes. Explorer window (upper
left window)

Page 82 Vicon Learning System


Excel XP Level 4 Lesson 5 - Using Macros

Steps Practice Data


2. Click the Project Explorer button on
the Standard toolbar. Click
The Project Explorer window opens.
3. Close the Properties window. Click on the Properties
The Properties window closes. window (lower left
window)
4. Click the Properties Window button
on the Standard toolbar. Click
The Properties window opens.
5. Close the Code window. Click on the Code
The Code window closes. window (on the menu bar)
6. Expand the Modules folder in the Click Modules
Project Explorer window.
The folder expands to display its
contents.
7. Double-click the module you want to Double-click Module 1
display.
The Code window opens with the
contents of the module displayed.

Notice that the module contains two macros, NewYork and Atlanta, which open
NEWYORK.XLS and ATLANTA.XLS respectively.

Close the Visual Basic Editor window and hide the Visual Basic toolbar.
Close CITY56.XLS.

Vicon Learning System Page 83


Lesson 5 - Using Macros Excel XP Level 4

EXERCISE
USING MACROS

ε Task
Use macros in a workbook.

1. Open Exer81 and enable the macros.


2. Run the Sort_RegionSales macro. Notice that the macro sorts the
data, first by region in ascending order, and then by annual sales in
descending order.
3. Now use the Visual Basic toolbar to run the Sort_LastName macro.
Notice that the macro sorts the data by last name in ascending order.
4. Use the [Ctrl+r] shortcut key to run the Subtotals_Region macro.
5. Open the Visual Basic Editor window.
6. Display the Module1 module in the Code window, if necessary.
Scroll as necessary to view the Subtotals_Remove macro.
7. Close the Visual Basic Editor window; then, run the
Subtotals_Remove macro.
8. Hide the Visual Basic toolbar.
9. Close the workbook without saving it.

Page 84 Vicon Learning System


LESSON 6 -
RECORDING MACROS

In this lesson, you will learn how to:


• Record a macro

• Assign a shortcut key

• Use relative references

• Assign a macro to a menu

• Remove a custom menu item

• Delete a macro
Lesson 6 - Recording Macros Excel XP Level 4

RECORDING A MACRO

δ Discussion
A macro can be created using the macro recorder. Excel records the macro as you
perform the steps you want to include in it. The steps you perform are not recorded as
simple keystrokes, however; they are translated into the Visual Basic for Application
programming language, which translates your steps into macro statements.

When you record a macro, Excel creates a module in the current worksheet. As you
perform the macro keystrokes, they are saved as Visual Basic language statements in
the module. A module can contain more than one macro.

During the macro recording process, you name the macro and enter descriptive
information about it. This information is entered into the Record Macro dialog box
and appears as a comment in the module.

In addition to naming the macro, you can select the location where you want to store
the macro. Macros can be stored in the current workbook, a new workbook, or the
Personal Macro Workbook. Macros stored in a workbook are only available when that
workbook is open. If you store a macro in the Personal Macro Workbook, however, it
will be available to all workbooks.

ο If you record a macro to the Personal Macro Workbook, you


are prompted to save the changes when you exit Excel.

ο You can also record a macro by selecting the Tools menu, the
Macro submenu, and then the Record New Macro command.

ξ Some words are reserved and cannot be used in a macro name;


invalid words are usually macro commands, such as Date, If,
or Next.

φ Step-by-Step
From the Student Data directory, open CITY57.XLS.
Record a macro.

If necessary, enable the macros and display the Visual Basic toolbar.

Page 86 Vicon Learning System


Excel XP Level 4 Lesson 6 - Recording Macros

Make sure that your current folder is set for the path containing the student data files.

Steps Practice Data


1. Click the Record Macro button on the
Visual Basic toolbar. Click
The Record Macro dialog box opens
with the text in the Macro name box
selected.
2. Type the desired macro name. Type Chicago
The text appears in the Macro name
box.
3. Select the Shortcut key box, if Press [Tab]
desired.
The insertion point appears in the
Shortcut key box.
4. Type the desired shortcut key Type e
character.
The character appears in the Shortcut
key box.
5. Select the Store macro in list. Click Store macro in
A list of available options appears.
6. Select the desired location. Click This Workbook, if
The location appears in the Store necessary
macro in box.
7. Select the text in the Description box. Press [Tab]
The text in the Description box is
selected.
8. Type the desired macro description. Type Opens the Chicago
The text appears in the Description workbook
box.
9. Select OK. Click OK
The Record Macro dialog box closes,
the word Recording appears on the
status bar, and the Stop Recording
toolbar appears.
10. Perform the first macro step.
The first step of the macro is recorded. Click
11. Perform additional macro steps as Double-click Chicago
needed.
The steps of the macro are recorded.

Vicon Learning System Page 87


Lesson 6 - Recording Macros Excel XP Level 4

Steps Practice Data


12. When you have finished recording
macro steps, click the Stop Recording Click
button on the Stop Recording toolbar.
The macro stops recording, and the
Stop Recording toolbar disappears.

Close the Chicago workbook. Then, open the Visual Basic Editor window and view
the macro by double-clicking Module2 in the Project Explorer window. Notice that
the macro also recorded the path to the Chicago workbook. Close the Visual Basic
Editor window.

Use the [Ctrl+e] shortcut key to run the Chicago macro. Then, close the Chicago
workbook.

ASSIGNING A SHORTCUT KEY

δ Discussion
You can assign a shortcut key to a macro, either when you create the macro or after
the macro has been created. After a shortcut key has been assigned to a macro, the
macro runs whenever the shortcut key is pressed. All macro shortcut keys must begin
with the [Ctrl] key followed by any character or with the [Ctrl+Shift] key
combination followed by any character.

If you assign a shortcut key while the macro is being created, it appears as a comment
in the module. When a shortcut key is assigned to an existing macro, this comment is
not automatically created. You can edit the macro text, however, to manually add the
comment.

Assigning a shortcut key

Page 88 Vicon Learning System


Excel XP Level 4 Lesson 6 - Recording Macros

ο Shortcut keys are assigned as you are recording a macro by


entering the desired shortcut key in the Record Macro dialog
box.

ξ You should avoid assigning macro shortcut keys that are the
same as the standard Excel shortcuts (e.g., [Ctrl+B],
[Ctrl+S]), because the standard Excel shortcut will be
overridden by the macro shortcut.

φ Step-by-Step
Assign a shortcut key to a macro.

If necessary, enable the macros and display the Visual Basic toolbar.

The macro used in the following step-by-step does not contain a file path. As a result,
it will look in the folder that contains the City57.xls data file. Make sure that your
current folder is set for the path containing the student data files.

Steps Practice Data


1. Click the Run Macro button on the
Visual Basic toolbar. Click
The Macro dialog box opens.
2. Select the macro to which you want to Click Atlanta, if
assign a shortcut key. necessary
The macro is selected.
3. Select Options. Click Options...
The Macro Options dialog box opens
with the insertion point in the Shortcut
key box.
4. Type the desired character. Type a
The character appears in the Shortcut
key box.
5. Select OK. Click OK
The Macro Options dialog box closes,
and the shortcut key is assigned to the
macro.
6. Select Cancel. Click Cancel
The Macro dialog box closes.

Vicon Learning System Page 89


Lesson 6 - Recording Macros Excel XP Level 4

Use the [Ctrl+a] shortcut key to run the Atlanta macro. Then, close the Atlanta
workbook.

USING RELATIVE REFERENCES

δ Discussion
Absolute and relative references refer to how a macro records cell locations. When
you use absolute references while recording a macro, Excel records absolute, or exact,
cells references. For example, if you enter the label Annual Sales Report in cell A4
while recording a macro with absolute references, that label will always appear in cell
A4 whenever you run the macro, no matter which cell is active.

When you use relative references while recording a macro, Excel records cell
references relative to the active cell. For example, if you type the label Annual Sales
Report in the cell to the left of the active cell while recording a macro with relative
references, that label will always be entered into the cell to the left of whichever cell is
active when you run the macro. Relative references give a macro more flexibility.

The Company macro code

φ Step-by-Step
Use relative references to record a macro.

Page 90 Vicon Learning System


Excel XP Level 4 Lesson 6 - Recording Macros

If necessary, enable the macros and display the Visual Basic toolbar.

Steps Practice Data


1. Select the desired cell. Click A14
The active cell moves accordingly.
2. Click the Record Macro button on the
Visual Basic toolbar. Click
The Record Macro dialog box opens
with the text in the Macro name box
selected.
3. Type the desired macro name. Type Company
The text appears in the Macro name
box.
4. Select OK. Click OK
The Record Macro dialog box closes,
the word Recording appears on the
status bar, and the Stop Recording
toolbar appears.
5. Click the Relative Reference button
on the Stop Recording toolbar. Click
Relative referencing is activated.
6. Record the first macro step.
The first step of the macro is recorded. Click
7. Record additional macro steps as Follow the instructions
desired. shown below the table
The steps of the macro are recorded. before continuing on to
the next step
8. When you have finished recording
macro steps, click the Stop Recording Click
button on the Stop Recording toolbar.
The macro stops recording, and the
Stop Recording toolbar disappears.

Format the current cell with italics and a font size of 14. Then, type Worldwide
Sporting Goods into the current cell and press [Enter].

Return to the table and continue on with the next step (step 8).

Clear the format and contents of cell A14 by selecting cell A14, selecting the Edit
menu, pointing to the Clear command, and selecting the All command. Then, select
cell A1 and run the Company macro to test it.

Vicon Learning System Page 91


Lesson 6 - Recording Macros Excel XP Level 4

Open the Visual Basic Editor window. Display the Company macro in the Module2
module. Then, close the Visual Basic Editor window.

Hide the Visual Basic toolbar.

ASSIGNING A MACRO TO A MENU

δ Discussion
You can assign a macro to a menu. The macro appears as a command on the selected
menu, and you can give it any name you want.

The macro command appears on the menu whether or not the workbook containing
the macro is open. You can execute the macro with any workbook, just as you can
execute any standard menu command. If the workbook containing the macro is not
open when you execute the command, Excel will automatically open it and then run
the macro.

To use the keyboard to select a menu command, you can type an ampersand (&)
before the letter you want to be underlined. For example, &Report appears as Report
on the menu and Re&port appears as Report. You can then display the menu and
press the underlined letter to run the macro.

Assigning a macro to a menu

Page 92 Vicon Learning System


Excel XP Level 4 Lesson 6 - Recording Macros

ο You can move the Customize dialog box as needed to drag the
Custom Menu Item command from the Commands list to
the desired location on a menu.

φ Step-by-Step
Assign a macro to a menu.

If necessary, enable the macros.

Steps Practice Data


1. Right-click any toolbar. Right-click any toolbar
The toolbar shortcut menu appears.
2. Select the Customize command. Click Customize...
The Customize dialog box opens.
3. Select the Commands tab. Click the Commands tab
The Commands page appears.
4. Select Macros from the Categories Scroll as necessary and
list box. click Macros
The contents of the Commands list box
changes accordingly.
5. Drag Custom Menu Item from the Drag Custom Menu Item
Commands list b ox to the desired to the View menu and
menu and then to the desired position then drop it below the
on the displayed menu. Header and Footer...
Custom Menu Item appears on the command
displayed menu when you release the
mouse button.
6. Select Modify Selection in the Click
Customize dialog box. Modify Selection
The Modify Selection menu appears.
7. Select the Name command. Click Name
The text in the Name box is selected.
8. Type the desired name for the custom Type &Company Name
menu item.
The text appears in the Name box.
9. Select the Assign Macro command on Click Assign Macro...
the Modify Selection menu.
The Assign Macro dialog box opens.

Vicon Learning System Page 93


Lesson 6 - Recording Macros Excel XP Level 4

Steps Practice Data


10. Select the macro you want to assign to Click Company
the custom menu item.
The macro is selected.
11. Select OK. Click OK
The Assign Macro dialog box closes
and the macro is assigned to the menu.
12. Select Close. Click Close
The Customize dialog box closes.

Save the City57 workbook and then close it. Create a new workbook. Then, select the
View menu and the Company Name command. Enable the macros. Notice that Excel
opens the file in which the Company macro is stored to access it.

Close the new workbook without saving it; leave the City57 workbook containing the
Company macro open.

REMOVING A CUSTOM MENU ITEM

δ Discussion
Once a macro has been assigned to a menu, it is available to all worksheets.

If you no longer want the macro to appear on the menu, you can remove the custom
menu item from the menu.

ο You can also remove a custom menu item by right-clicking


the Tools menu and selecting the Customize command, Then
right-click the custom menu item and select the Delete
command.

ο You do not have to have a workbook open in order to delete a


custom menu item.

φ Step-by-Step
Remove a custom menu item from a menu.

Page 94 Vicon Learning System


Excel XP Level 4 Lesson 6 - Recording Macros

Steps Practice Data


1. Right-click any toolbar. Right-click any toolbar
The toolbar shortcut menu appears.
2. Select the Customize command. Click Customize…
The Customize dialog box opens.
3. Select the menu containing the custom Click View
menu item you want to remove.
The menu is selected.
4. Drag the custom menu item you want Drag Company Name off
to remove away from the menu. of the View menu
The custom menu item is removed
from the menu.
5. Select Close. Click Close
The Customize dialog box closes.

DELETING A MACRO

δ Discussion
If you no longer use a macro, you can delete it. Since macros can invoke other
macros, you should make sure that the macro you are deleting is not needed by
another macro.

If a macro is stored in a workbook, the workbook must be open in order to delete the
macro. If the macro is stored in the Personal Macro Workbook, which automatically
loads as a hidden window every time you open Excel, the Personal Macro Workbook
window must be unhidden before the macro can be deleted.

ο You can unhide the Personal Macro Workbook by selecting


the Window menu, the Unhide command, Personal.xls in the
Unhide dialog box, and then OK.

ο If you delete a macro from the Personal Macro Workbook,


Excel prompts you to save the changes to the Personal Macro
Workbook when you exit Excel.

ο You can also open the Macro dialog box by selecting the
Tools menu, pointing to the Macro command, and selecting
the Macros command.

Vicon Learning System Page 95


Lesson 6 - Recording Macros Excel XP Level 4

φ Step-by-Step
Delete a macro.

If necessary, enable the macros and display the Visual Basic toolbar.

Steps Practice Data


1. Click the Run Macro button on the
Visual Basic toolbar. Click
The Macro dialog box opens.
2. Select the macro you want to delete. Click Company
The macro is selected.
3. Select Delete. Click Delete
The Macro dialog box closes, and a
Microsoft Excel message box opens to
ask you to confirm the deletion.
4. Select Yes. Click Yes
The Microsoft Excel message box
closes, and the macro is deleted.

Hide the Visual Basic toolbar.


Close CITY57.XLS.

Page 96 Vicon Learning System


Excel XP Level 4 Lesson 6 - Recording Macros

EXERCISE
RECORDING MACROS

ε Task
Record macros.

1. Open Exer82 and enable the macros.


2. Display the Last Year worksheet, if necessary. In cell A1, begin
recording a macro named Today. Store the macro in the current
workbook.
3. Using relative references, perform the following steps to record the
Today macro:

Add bold and a red font color to the active cell


Change the font size to 12
Type =today()
Press [Enter]
4. Stop recording the macro. Clear the format and contents from cell
A1. (Hint: Use the Edit menu.)
5. View the macro in the Visual Basic Editor window, displaying
Module3 in the Code window, if necessary. Then, close the Visual
Basic Editor window.
6. Add the Today macro to the Tools menu, below the Macro
command. Move the Customize dialog box if it is in the way. Name
the custom menu item Today. (Hint: Use an ampersand to add the
underline.)
7. Display the Projections worksheet. Use the Today command on the
Tools menu to run the Today macro in cell A1.
8. Clear the format and contents from cell A1. (Hint: Use the Edit
menu.)
9. Assign the [Ctrl+Shift+T] shortcut key to the Today macro.
10. Use the shortcut key to run the Today macro in cell A1 in the Last
Year worksheet.
11. Remove the Today command from the Tools menu. (Hint: Use the
Customize dialog box.)
12. Delete the Today macro.

Vicon Learning System Page 97


Lesson 6 - Recording Macros Excel XP Level 4

13. Hide the Visual Basic toolbar.


14. Close the workbook without saving it.

Page 98 Vicon Learning System


LESSON 7 -
EDITING MACROS

In this lesson, you will learn how to:


• Write a new macro

• Enter macro comments

• Copy macro commands

• Edit macro commands

• Type macro commands

• Run a macro from the Code window


Lesson 7 - Editing Macros Excel XP Level 4

WRITING A NEW MACRO

δ Discussion
New macros can be created by recording the steps or typing the commands directly
into the Code window in the Visual Basic Editor. To write a new macro in the Visual
Basic Editor Code window, you must type the word Sub, followed by the macro name
and a set of parentheses ( ( ) ). Excel automatically supplies the End Sub command.
All steps in the procedure must be entered between the Sub and End Sub commands.

New macros can be inserted in an existing module or added to a new module. You can
insert a macro above or below any existing macro; the position of the macro in the
module does not affect its performance.

Writing a new macro

ο You can create a new module in a Visual Basic project by


selecting the Insert menu and then the Module command. A
new module with an incremental number, such as Module 3,
will then be inserted into the current project or workbook.

ο When you insert a macro above or below an existing macro,


the Visual Basic Editor automatically inserts horizontal lines
between macros to separate them.

Page 100 Vicon Learning System


Excel XP Level 4 Lesson 7 - Editing Macros

φ Step-by-Step
From the Student Data directory, open CITY58.XLS.
Write a new macro.

If necessary, enable the macros.

Open the Visual Basic Editor window and display Module1 in the Code window.

Steps Practice Data


1. Position the insertion point below any Press [Ctrl+End]
existing macros.
The insertion point appears at the
selected location in the Code window.
2. Type Sub. Type Sub
The Sub command appears at the
insertion point.
3. Press [Spacebar]. Press [Spacebar]
A space appear after the Sub
command.
4. Type the macro name, followed by a Type Open_Cities()
set of parentheses ( ( ) ).
The text and parentheses appear at the
insertion point.
5. Press [Enter]. Press [Enter]
The insertion point moves to the next
line, the End Sub command appears
on the line below the insertion point,
and a horizontal line appears above
the Sub command.

Scroll, if necessary, to view the End Sub command.

ENTERING MACRO COMMENTS

δ Discussion
When macros are first recorded, the recording process documents the name, date, and
other macro descriptions in the Code window. This information appears before the
actual macro statements. If you make a change to a macro, you should go into the

Vicon Learning System Page 101


Lesson 7 - Editing Macros Excel XP Level 4

documentation area of the macro and edit this information as necessary. For example,
if you add a shortcut key to a macro after the macro has been recorded, this
information is not automatically added to the macro documentation. You must
manually add a line to document the change.

In longer and more complex macros, you can add comments to the various macro
steps. Comments can explain what a step or series of steps should accomplish. This
information can be helpful if the macro must be modified or debugged at some later
date.

Comments must begin with a single apostrophe ('). Excel treats any line that begins
with a single apostrophe as a comment. Comments can appear either on a separate line
or adjacent to a macro statement. Comments appear in black text when they are
entered and change to green text as soon as you move to another line.

φ Step-by-Step
Enter macro comments.

If necessary, enable the macros, open the Visual Basic Editor window, and display
Module1 in the Code window.

Steps Practice Data


1. Position the insertion point where you Click in the blank line
want to add the comment. below Sub
The insertion point moves accordingly. Open_Cities(), if
necessary
2. Type an apostrophe ('). Type '
The apostrophe (') appears in the line.
3. Press [Spacebar]. Press [Spacebar]
A space appears after '.
4. Type the desired comment text. Type This macro opens
The comment text appears in the three city files
macro.
5. Press [Enter]. Press [Enter]
The insertion point moves to the next
line, and the comment text turns green.

Practice the Concept: Display Module2 in the Code window. In the Company
macro, click in the blank line above the Selection.Font.Bold = True command. Type
an apostrophe ('), a space, and the following comment: Formats the current cell.
Press [Enter].

Page 102 Vicon Learning System


Excel XP Level 4 Lesson 7 - Editing Macros

Scroll as necessary and click at the end of the End With command in the same macro;
press [Enter] to add a new line. Then, type the following comment: ' Inserts the
company name. Remove the spacing to the left of the apostrophe. Click in the next
line to see the comment color change to green.

COPYING MACRO COMMANDS

δ Discussion
There may be times when you want to combine macros for a more efficient operation.
For example, if three different macros each open one of three separate workbooks,
you can combine the three macros into one to open all three workbooks in one step.
You can combine macros by copying and pasting the command statements from one
macro to another. Macro commands can be copied from other macros, other modules,
or even other workbooks.

Copying macro commands saves the time it takes to re-record a macro or to write one
or more new macro steps.

ο If an error occurs while running a macro, the Microsoft Visual


Basic dialog box opens. You can select the End button to stop
running the macro. If you select the Debug button, the Visual
Basic Editor window opens with the command that created the
error highlighted. You can fix the error and click the Continue
button on the Standard toolbar to continue the macro, or you
can click the Reset button on the Standard toolbar to stop
debugging the macro.

φ Step-by-Step
Copy macro commands between modules.

If necessary, enable macros, open the Visual Basic Editor window, open Module1 in
the Code window, and display the NewYork macro.

Make sure that your current folder is set for the path containing the student data files.

Steps Practice Data


1. Select the macro text you want to Drag to select the
copy. Workbooks.Open
The macro text is selected. Filename:=
“NEWYORK.XLS” text

Vicon Learning System Page 103


Lesson 7 - Editing Macros Excel XP Level 4

Steps Practice Data


2. Click the Copy button on the Visual
Basic Editor Standard toolbar. Click
The text is copied to the Office
Clipboard.
3. Position the insertion point where you Scroll as necessary and
want to paste the macro text. click in the Open_cities
The insertion point appears in the macro in the line above
desired location. the End Sub command
4. Click the Paste button on the Visual
Basic Editor Standard toolbar. Click
The copied macro text is pasted at the
insertion point.

Click to the left of the Workbooks.Open Filename:= “NEWYORK.XLS” macro


line and press [Tab] to indent it.

Practice the Concept: Copy the step in the Atlanta macro that opens the Atlanta
workbook and paste it into the Open_Cities macro, on a line below the step that
opens the Newyork file. Then, open Module2 in the Code window and copy the step
in the Chicago macro that opens the Chicago workbook and paste it into the
Open_Cities macro, on a line below the step that opens the Atlanta file. All three
macro commands should appear above the End Sub command.

Close the Visual Basic Editor window. Run the Open_Cities macro. Then, run the
Close_Cities macro to close the Newyork, Atlanta, and Chicago workbooks.

EDITING MACRO COMMANDS

δ Discussion
Depending on the changes you need to make, it may be easier to edit the macro text
rather than to delete the entire macro and record it again. You can use standard editing
techniques to edit macro text.

ο You can rename a macro by changing the macro name in the


Sub command. You may want to change any associated
comments, descriptions, or shortcut keys. Changing comment
text in the Code window does not change the text or shortcut
key in the macro itself; you must use the Options button in the
Macro dialog box to make those changes.

Page 104 Vicon Learning System


Excel XP Level 4 Lesson 7 - Editing Macros

ο You can rename a module in the Visual Basic Editor by


selecting the module in the Project Explorer window and
typing the desired name into the (Name) box in the Properties
window.

ξ Be careful when editing command statements; if you do not


use the correct syntax and punctuation, the macro may not
work correctly or may not run at all.

φ Step-by-Step
Edit macro commands manually.

If necessary, enable the macros and display the Visual Basic toolbar.

Make sure that your current folder is set for the path containing the student data files.

Steps Practice Data


1. Select the Run Macro button on the
Visual Basic toolbar. Click
The Macro dialog box opens.
2. Select the macro you want to edit. Click Open_Cities
The macro name is selected.
3. Select Edit. Click Edit
The Macro dialog box closes, the
Visual Basic Editor opens, and the
insertion point appears in the selected
macro.
4. Select the text you want to edit. Double-click the word
The text is selected. NEWYORK in the
Open_Cities macro
5. Make the desired text changes. Type tampa
The text changes accordingly.

Practice the Concept: Open Module2. Scroll as necessary to view the Close_Cities
macro. Replace the word NEWYORK with tampa in the first Workbooks().Close
command.

Close the Visual Basic Editor window and run the Open_Cities macro. Notice that
the macro now opens the Tampa workbook instead of the Newyork workbook.

Vicon Learning System Page 105


Lesson 7 - Editing Macros Excel XP Level 4

Use the Close_Cities macro to close the other three workbooks.


Close CITY58.XLS.

TYPING MACRO COMMANDS

δ Discussion
In addition to recording macro commands, you can also type them directly into a
macro procedure. Macro procedures work with statements and objects. Some macro
steps, such as macro statements, cannot be recorded. For example, you may want to
create a condition that executes specific macro commands if the condition is true and
other commands if the condition is false.

Objects are the elements upon which the macro acts, such as a workbook, worksheet,
range, cell, or chart. A collection is a set of multiple objects. The worksheets in a
workbook are part of a collection. You use VBA (Visual Basic for Applications)
commands to change the properties of an object or collection or to apply a method
(action) to an object. The properties and methods differ depending upon the object.

When entering a command, you must use the proper syntax. The syntax of a command
is the structure of its elements. As you type commands in the Visual Basic Editor, lists
with available properties or methods may appear.

There is often more than one way to perform the same action. For example, you can
record a macro that deletes the contents in the range A6:F12 in the Sales worksheet.
The steps could be recorded using the following selection methods since you would be
manually selecting the worksheet and range.

Sheets(“SALES”).Select
Range(“A6:F12”).Select
Selection.ClearContents

You can accomplish the same result by writing a command, such as the one shown
below, that applies a method to the specified object. The object is the range A6:F12 in
the Sales worksheet. The command assumes that the correct workbook is open and
can be written without the Worksheets property if the command to activate the
worksheet was issued in a previous step.

Worksheets(“SALES”).Range(“A6:F12”).ClearContents

If a group of commands can be recorded, it might be easier to record the macro steps
in a separate macro and then copy and paste them into the larger macro than it would
be to write them directly into the Code window.

Page 106 Vicon Learning System


Excel XP Level 4 Lesson 7 - Editing Macros

ο The Visual Basic Editor provides a variety of help features. As


you type a command, pop-up help may appear. The Auto
Quick Info box and the Auto List Member list both provide
help with either parameters or available methods and
properties. The syntax of your command is automatically
verified when you move to another line.

φ Step-by-Step
From the Student Data directory, open CITY59.XLS.
Type a macro command.

If necessary, enable the macros, open the Visual Basic Editor window, open the
Module1 module, and scroll as necessary to display the Open_Cities macro.

Make sure that your current folder is set for the path containing the student data files.

Steps Practice Data


1. Position the insertion point where you Click at the end of the
want to insert the command. Workbooks.Open
The insertion point moves accordingly. Filename:=
“CHICAGO.XLS” text
2. Press [Enter]. Press [Enter]
The insertion point moves to the next
line.
3. Type the desired command. Type
The text appears in the macro, and an workbooks(“city59.xls”)
Auto Quick Info box may appear.
4. To enter a property or method, type a Type a period (.)
period (.).
An Auto List Member list displays
available properties or methods.
5. Type the desired property or method Double-click Activate
or select it from the Auto List
Member list.
The property or method appears in the
command.
6. Press [Enter]. Press [Enter]
The command syntax is verified.

Vicon Learning System Page 107


Lesson 7 - Editing Macros Excel XP Level 4

Press [Alt+F11] to switch to the worksheet window. Run the Open_Cities macro.
When the macro ends, the City59 workbook should be active. Then, run the
Close_Cities macro. All workbooks should close, except the City59 workbook.

RUNNING A MACRO FROM THE CODE WINDOW

δ Discussion
During the editing process, a macro can be run directly from the Visual Basic Editor
using the Run Sub/UserForm button or the Run Sub/UserForm command on the
Run menu.

If you use the Run menu, you must position the insertion point in the Code window,
within the text of the macro you want to run. Otherwise, the Macro dialog box will
open and you must select and run the desired macro.

ο You can also run a macro directly from the Visual Basic
Editor by pressing the [F5] key.

φ Step-by-Step
Run a macro from the Code window.

If necessary, enable the macros, open the Visual Basic Editor window, and open
Module3.

Scroll as necessary to view the Urban_Update macro in Module3. Notice that it


opens the Tampa, Atlanta, and Chicago workbooks; runs the CleanUp macro;
consolidates the data from the three workbooks into the City59 workbook; formats the
consolidation table; runs the Company macro; and then closes the Tampa, Atlanta,
and Chicago workbooks.

Steps Practice Data


1. Click anywhere in the macro you want Click anywhere in the
to run. Urban_Update macro
The insertion point appears in the new
location.
2. Click the Run Sub/UserForm button
on the Visual Basic Editor Standard Click
toolbar.
The macro commands are executed.

Page 108 Vicon Learning System


Excel XP Level 4 Lesson 7 - Editing Macros

Close the Visual Basic Editor window. Notice the consolidated data in the City59
workbook.

Notice the consolidated value in cell C6 of $10,703. Open the Atlanta workbook and
change cell C7 from 3250 to 9250; then, close and save the Atlanta workbook. Run
the Urban_Update macro from the City59 workbook window; notice that the
consolidated value in cell C6 changes to $16,703.

Hide the Visual Basic toolbar.


Close CITY59.XLS.

Vicon Learning System Page 109


Lesson 7 - Editing Macros Excel XP Level 4

EXERCISE
EDITING MACROS

ε Task
Edit macros with the Visual Basic Editor.

1. Open Exer83 and enable the macros.


2. If necessary, display the Visual Basic toolbar.
3. View Exer83 in print preview. Notice the portrait page orientation;
then close print preview.
4. Open the Visual Basic Editor window and open Module1 in the
Code window, if necessary.
5. Go to the top of the Code window, if necessary, and press [Enter]
twice to move the Sub Sort_RegionSales() command down two
lines.
6. Go back to the top of the Code window, type
Sub Sort_RegionLastN(), and press [Enter].
7. Enter the following comment: Sorts by region and then by last
name. Then, press [Enter]. (Hint: Remember to begin the comment
with a single apostrophe.)
8. Copy the all the macro steps from the Sort_RegionSales macro to
the Sort_RegionLastN macro.
9. In the Sort_RegionLastN macro, change the cell reference in
Key2:=Range(“J6”) to a6 and change the Order2:=xlDescending
argument to Order2:=xlascending.
10. Create a blank line above the End Sub command; type the
following macro command on the line:
ActiveSheet.PageSetup.Orientation = xlLandscape; and press
[Enter].

Page 110 Vicon Learning System


Excel XP Level 4 Lesson 7 - Editing Macros

11. Run the Sort_RegionLastN macro from the Visual Basic Editor
window. (Hint: Make sure to click anywhere in the macro text
before running the macro.)
12. Close the Visual Basic Editor window.
13. Notice that the list in the Exer83 workbook window is now sorted
first by region and then by last name. Switch to print preview; notice
the landscape page orientation. Then, close print preview.
14. Hide the Visual Basic toolbar.
15. Close the workbook without saving it.

Vicon Learning System Page 111


LESSON 8 -
USING CUSTOM TOOLBARS AND MENUS

In this lesson, you will learn how to:


• Create a custom toolbar

• Add/Remove toolbar buttons

• Add the Custom Button to a toolbar

• Assign a macro to a button

• Change a button image

• Display button text and image

• Attach a custom toolbar

• Delete a custom toolbar

• Create a custom menu

• Add custom menu commands


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

CREATING A CUSTOM TOOLBAR

δ Discussion
You can create a custom toolbar in Excel. This option allows you to group buttons
you use regularly on one toolbar.

Custom toolbars are not saved with any particular workbook; rather they are saved to
the Excel application itself. As a result, a custom toolbar is available at any time, with
any workbook.

The custom toolbar name appears on the toolbar shortcut menu, as well as on the
Toolbars page in the Customize dialog box.

Creating a custom toolbar

φ Step-by-Step
From the Student Data directory, open MAC8.XLS.
Create a custom toolbar.

If necessary, enable the macros.

Page 114 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

Steps Practice Data


1. Right-click any toolbar. Right-click any toolbar
The toolbar shortcut menu appears.
2. Select the Customize command. Click Customize…
The Customize dialog box opens.
3. Select the Toolbars tab. Click the Toolbars tab, if
The Toolbars page appears. necessary
4. Select New. Click New...
The New Toolbar dialog box opens
with the text in the Toolbar name box
selected.
5. Type the desired toolbar name. Type My Toolbar
The text appears in the Toolbar name
box.
6. Select OK. Click OK
The New Toolbar dialog box closes,
the new toolbar name is selected in the
Toolbars list box in the Customize
dialog box, and a blank toolbar
appears.

ADDING/REMOVING TOOLBAR BUTTONS

δ Discussion
Once you have created a custom toolbar, you can add buttons to it. Many more
buttons are available than those you see on the built-in toolbars.

All available buttons are listed on the Commands page in the Customize dialog box.
When the Customize dialog box is open, any of these buttons can be added, edited,
deleted, or moved. In order to add a button to a toolbar, the toolbar must be displayed.

The Description button on the Commands page displays the ScreenTip for the
selected button.

ο Many of the commands available in the Customize dialog box


are accompanied by a button; this button will appear on any
toolbar to which you add the command. If a command does
not have an accompanying button, the name of the command
will appear on the toolbar instead.

Vicon Learning System Page 115


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

φ Step-by-Step
Add or remove a toolbar button.

If necessary, open the Customize dialog box and display the My Toolbar toolbar.

Steps Practice Data


1. Select the Commands tab. Click the Commands tab
The Commands page appears.
2. Select the desired category from the Click File, if necessary
Categories list box.
The commands in the selected
category appear in the Commands list
box.
3. Select the command you want to add Scroll the Commands list
from the Commands list box. box as necessary and click
The command is selected. Save
4. Drag the command to the toolbar. Drag Save to the My
The command appears on the toolbar Toolbar toolbar
when you release the mouse button.
5. To remove a command from a toolbar,
drag it off the toolbar. Drag away from the
The button is removed from the My Toolbar toolbar
toolbar.

Practice the Concept: Scroll as necessary and add the Print button from the File
category to the My Toolbar toolbar.

Leave the Customize dialog box open.

ADDING THE CUSTOM BUTTON TO A TOOLBAR

δ Discussion
All the categorized commands in the Commands list box in the Customize dialog box
have commands attached to them, except for those in the Macros category. You can
add the Custom Button command in the Macros category to a toolbar and then attach
the desired command (usually a macro) to the custom button.

Page 116 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

Adding the Custom Button to a toolbar

φ Step-by-Step
Add the Custom Button command to a toolbar.

If necessary, open the Customize dialog box, and display the Commands page and
the My Toolbar toolbar.

Steps Practice Data


1. Select Macros from the Categories Scroll as necessary and
list box. click Macros in the
The commands in the Macros category Categories list box
appear in the Commands list box.
2. Select the Custom Button command Click Custom Button in
from the Commands list box. the Commands list box
The Custom Button command is
selected.
3. Drag the Custom Button command to Drag Custom Button to
the desired position on the toolbar.
The button associated with the Custom the right of on the
Button command appears on the My Toolbar toolbar
toolbar when you release the mouse
button.

Leave the Customize dialog box open.

Vicon Learning System Page 117


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

ASSIGNING A MACRO TO A BUTTON

δ Discussion
Once a custom button has been added to a toolbar, you must assign a command to it.
Usually, the command you assign is a macro. Once assigned, the macro will run
whenever the button is clicked.

Since toolbars are saved with Excel rather than with any particular workbook, the
commands on a custom toolbar are available to all workbooks. If you assign a macro
stored in a workbook to a custom button, the macro executes only when the workbook
containing the macro is open. If the workbook containing the macro is closed when
you click the custom button, Excel will automatically open it in order to run the
macro, prompting you to enable the macros in it, if necessary.

φ Step-by-Step
Assign a macro to a custom button.

If necessary, open the Customize dialog box, and display the Commands page and
the My Toolbar toolbar.

Steps Practice Data


1. Select the custom button to which you
want to assign a macro. Click on the My
The custom button is selected. Toolbar toolbar, if
necessary
2. Select Modify Selection. Click
The Modify Selection menu appears. Modify Selection
3. Select the Assign Macro command. Click Assign Macro...
The Assign Macro dialog box opens.
4. Select the macro you want to assign to Click Today
the custom button.
The macro name appears in the Macro
name box.
5. Select OK. Click OK
The Assign Macro dialog box closes,
and the macro is attached to the
custom button.

Page 118 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

Close the Customize dialog box. Then, select cell A5 and click the custom button on
the My Toolbar toolbar. Notice that the macro inserts today’s date into the selected
cell.

CHANGING A BUTTON IMAGE

δ Discussion
When a custom button has been added to a toolbar, its default button image appears
on the toolbar. You may, however, want the button image to be easily recognized or to
reflect the action the macro executes.

You can easily change a button image; Excel provides numerous images from which
you can choose. In addition, you can edit an existing button image as desired.

Changing a button image

φ Step-by-Step
Change a button image.

Open the Customize dialog box and display the Commands page.

If necessary, display the My Toolbar toolbar.

Vicon Learning System Page 119


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

Steps Practice Data


1. Select the button with the image you
want to change. Click on the My
The button is selected. Toolbar toolbar
2. Select Modify Selection. Click
The Modify Selection menu appears. Modify Selection
3. Point to the Change Button Image Point to Change Button
command. Image
A palette of available button images
appears.
4. Select the desired image.
The image appears on the button. Click (second row,
third column)

Leave the Customize dialog box open.

DISPLAYING BUTTON TEXT AND IMAGE

δ Discussion
By default, a toolbar button displays only the button image. You can display text as
well to better identify a button, or you can display only button text and no image.

Displaying button text can be especially helpful to someone unfamiliar with the
default button images, or if you have added numerous custom buttons to custom or
default toolbars.

Page 120 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

Adding text to a button

φ Step-by-Step
Display both button text and image.

If necessary, open the Customize dialog box, and display the Commands page and
the My Toolbar toolbar.

Steps Practice Data


1. Select the toolbar button you want to
modify. Click on the My
The button is selected. Toolbar toolbar, if
necessary
2. Select Modify Selection. Click
The Modify Selection menu appears. Modify Selection
3. Select the Name command. Click Name
The text in the Name box is selected.
4. Type the desired button text. Type Date
The text appears in the Name box.
5. Select the Image and Text command. Click Image and Text
The button text is added to the toolbar.

Leave the Customize dialog box open.

Vicon Learning System Page 121


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

ATTACHING A CUSTOM TOOLBAR

δ Discussion
When you create a custom toolbar, it is stored by default in Excel itself, not in any
particular workbook. Therefore, it is available to all workbooks. A custom toolbar
can, however, be attached to a specific workbook as well.

The advantage to attaching a custom toolbar to a workbook is that the toolbar will
always be available to the workbook, regardless of the computer on which you open
it. If you intend to share a workbook or to copy the workbook to another computer, it
is a good idea to attach the custom toolbar so that anyone who opens the workbook
can use it.

After a workbook containing a custom toolbar has been opened on any computer, the
custom toolbar appears in the list of available toolbars for that computer, even when
the workbook is closed.

Attaching a custom toolbar

ο You can use the Attach Toolbars dialog box to attach and
remove custom toolbars from a workbook. The Copy button
changes to a Delete button when you click a custom toolbar in
the Toolbars in workbook list box.

Page 122 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

φ Step-by-Step
Attach a custom toolbar to a workbook.

If necessary, open the Customize dialog box.

Steps Practice Data


1. Select the Toolbars tab. Click the Toolbars tab
The Toolbars page appears.
2. Select Attach. Click Attach...
The Attach Toolbars dialog box opens.
3. Select the custom toolbar you want to Click My Toolbar
attach from the Custom toolbars list
box.
The toolbar name is selected.
4. Select Copy. Click Copy >>
The toolbar is copied to the Toolbars
in workbook list box.
5. Select OK. Click OK
The Attach Toolbars dialog box closes.

Close the Customize dialog box and save the workbook.

DELETING A CUSTOM TOOLBAR

δ Discussion
You can delete a custom toolbar if you no longer use it. Deleting a custom toolbar
completely removes it from Excel. A workbook does not have to be open to delete a
custom toolbar.

Deleting a custom toolbar from Excel, however, does not delete it from any workbook
to which it has been attached. Consequently, if you delete a custom toolbar and then
open a workbook to which it has been attached, the custom toolbar is added to Excel
and is again available to any workbook.

Vicon Learning System Page 123


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

Deleting a custom toolbar

φ Step-by-Step
Delete a custom toolbar.

Open the Customize dialog box.

Steps Practice Data


1. Select the Toolbars tab. Click the Toolbars tab, if
The Toolbars page appears. necessary
2. Select the toolbar you want to delete. Scroll as necessary and
The toolbar name is selected. click My Toolbar
3. Select Delete. Click Delete
A Microsoft Excel warning box opens,
prompting you to confirm the deletion.
4. Select OK. Click OK
The Microsoft Excel warning box
closes, and the toolbar is deleted.

Leave the Customize dialog box open.

Page 124 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

CREATING A CUSTOM MENU

δ Discussion
You can create one or more custom menus to store commands for commonly-used
tasks. Custom menus allow you to group commands on one menu, instead of having
to use several menus to perform functions.

Like a standard menu, a custom menu displays a list of commands and submenu
commands, if applicable. The first level of a custom menu, the menu name, appears
on the menu bar. A submenu command on any menu displays an arrow to the right of
its name, indicating that there are additional items that appear when the submenu is
selected.

When you create a custom menu, you can add it to the menu bar or any toolbar. You
can also add a custom menu to any standard menu (such as the Tools menu) or
another custom menu.

New menus and submenus are given the default name, New Menu. After a menu
command has been added, you can change its name. You can assign a shortcut key to
a menu name or command by typing an ampersand (&) to the left of the desired
shortcut key; the letter following the ampersand will then be underlined in the menu
name or command.

Once a custom menu has been created, it is available to all workbooks.

Creating a custom menu

Vicon Learning System Page 125


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

ο To add a custom menu to another menu, drag the New Menu


item to the desired menu and, when the menu expands, drag it
to the desired position on the menu.

ο You can use the Delete command on the Modify Selection


menu to delete a menu item. In addition, you can use the
Begin a Group command to insert a vertical separator to the
left of or above a menu item. You can also right-click any
menu item to access the Modify Selection menu.

φ Step-by-Step
Create a custom menu.

If necessary, open the Customize dialog box.

Steps Practice Data


1. Select the Commands tab. Click the Commands tab
The Commands page appears.
2. Select New Menu from the Scroll as necessary and
Categories list box. click New Menu
The New Menu command appears in
the Commands list box.
3. Drag New Menu from the Commands Drag New Menu to the
list box to the desired menu bar or right of Help on the menu
toolbar location. bar
The New Menu menu appears on the
appropriate menu bar or toolbar when
you release the mouse button.
4. Select Modify Selection. Click
The Modify Selection menu appears. Modify Selection
5. Select the Name command. Click Name
The text in the Name box is selected.
6. Type the desired menu name. Type &Open
The text appears in the Name box.
7. Press [Enter]. Press [Enter]
The menu is renamed.

Close the Customize dialog box. Select the Open menu; notice that an empty menu
appears.

Page 126 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

ADDING CUSTOM MENU COMMANDS

δ Discussion
After a custom menu has been created, you should add commands to it. You can
assign an existing Word command, a submenu, or a macro to any menu, not just to
custom menus.

To add a macro to a custom menu, the workbook or template in which it is stored


must be open. The easiest way to make sure that a macro is always available is to save
it to the Workbook template.

You can delete a menu, submenu, or menu command when you no longer need it.
Deleting a menu or submenu deletes all the commands and submenus on it. Deleting a
menu or submenu, however, deletes only the macro commands on it, not the macros
themselves.

Adding custom menu commands

ο To delete a menu, you can open the Customize dialog box,


right-click the menu you want to delete, and select the Delete
command from the shortcut menu.

ο You can restore a toolbar or menu bar to its original settings


by opening the Customize dialog box, selecting the Toolbars
tab, the menu bar or the toolbar you want to reset, and then the
Reset command. When you are prompted, select the template
you want to reset and select OK.

Vicon Learning System Page 127


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

φ Step-by-Step
Add menu commands to a custom menu.

Open the Customize dialog box.

If necessary, display the Commands page.

Make sure that your current folder is set for the path containing the student data files.

Steps Practice Data


1. Select Macros from the Categories Scroll as necessary and
list box. click Macros
The commands in the Macros category
appear in the Commands list box.
2. Drag the Custom Menu Item Drag Custom Menu Item
command to the desired menu to the Open menu
location.
The Custom Menu Item command
appears on the menu when you release
the mouse button.
3. Select Modify Selection. Click
The Modify Selection menu appears. Modify Selection
4. Select the Name command. Click Name
The text in the Name box is selected.
5. Type the desired menu name. Type &Atlanta
The text appears in the Name box.
6. Select Assign Macro. Click Assign Macro...
The Assign Macro dialog box opens.
7. Select the desired macro. Click Atlanta
The macro name appears in the Macro
name box.
8. Select OK. Click OK
The Assign Macro dialog box closes,
and the macro is attached to the menu
command.

Page 128 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

Steps Practice Data


9. Add additional commands to the Follow the instructions
custom menu, as desired. shown below the table
The menu commands appear on the before continuing on to
custom menu. the next step
10. Select Close. Click Close
The Customize dialog box closes.

Add the following menu commands to the Open menu and attach the indicated
macros:

Menu name Macro attached


Chicago Chicago
New York NewYork

Return to the table and continue on with the next step (step 10).

Select each of the custom menu commands to test it.

Open the Customize dialog box, delete the Open menu by dragging it off the menu
bar, and then close the Customize dialog box.
Close MAC8.XLS, ATLANTA.XLS, CHICAGO.XLS, and NEWYORK.XLS.

Vicon Learning System Page 129


Lesson 8 - Using Custom Toolbars and Menus Excel XP Level 4

EXERCISE
USING CUSTOM TOOLBARS AND MENUS

ε Task
Work with custom toolbars and menus.

1. Open Exer84 and enable the macros.


2. Create a custom toolbar named Reports.
3. Add the Close and Print... buttons to the Reports toolbar. (Hint:
Use the File category.)
4. Add a custom button to the right of the Print button on the Reports
toolbar. (Hint: Use the Macros category.)
5. Name the custom button Regions, assign the Report_Landscape
macro to it, and display both image and text.
6. Change the button image of the Regions button; select the open book
image (sixth row, first column).
7 Remove the Close button from the Reports toolbar.
8. Attach the Reports toolbar to the Exer84 workbook.
9. Add a custom menu to the right of the Help menu named Sort.
10. Add a custom menu item to the Sort menu. Name it SortLN and
assign the Sort_LastName macro to it.

Page 130 Vicon Learning System


Excel XP Level 4 Lesson 8 - Using Custom Toolbars and Menus

11. Close the Customize dialog box. Test the Regions button on the
Reports toolbar. It should create a regional subtotals report,
formatted with a landscaped orientation. Then, test the SortLN
command; select OK in the Microsoft Excel warning box.
12. Delete the Reports toolbar and the Sort menu.
13. Close the workbook without saving it.

Vicon Learning System Page 131


LESSON 9 -
CREATING A MACRO BUTTON

In this lesson, you will learn how to:


• Use a macro button

• Create a macro button

• Copy a macro button

• Format a macro button

• Move/Size a macro button

• Delete a macro button


Lesson 9 - Creating a Macro Button Excel XP Level 4

USING A MACRO BUTTON

δ Discussion
You can create a button right in your worksheet that will run an associated macro.
Macro buttons can simplify your work, automate repetitive tasks, or help an
inexperienced user perform various worksheet tasks.

You can draw a macro button anywhere on the worksheet, as well as create as many
macro buttons as needed to perform different worksheet tasks.

Like other graphic objects, macro buttons float above the worksheet.

φ Step-by-Step
From the Student Data directory, open CITY60.XLS.
Use a macro button.

If necessary, enable the macros.

The macro used in the following step-by-step does not contain a file path. As a result,
it will look in the folder that contains the City60.xls data file. Make sure that your
current folder is set for the path containing the student data files.

Steps Practice Data


1. Click the desired macro button. Click Open Atlanta
The associated macro runs.

Close ATLANTA.XLS.

CREATING A MACRO BUTTON

δ Discussion
The Forms toolbar is used to create a macro button. After you have drawn the macro
button, you must assign a macro to it. You can then size the macro button and position
it anywhere on the worksheet.

When the macro button is clicked, the macro attached to it runs.

Page 134 Vicon Learning System


Excel XP Level 4 Lesson 9 - Creating a Macro Button

Creating a macro button

φ Step-by-Step
Create a macro button.

If necessary, enable the macros.

Display the Forms toolbar.

Steps Practice Data


1. Click the Button button on the Forms
toolbar. Click
The mouse pointer changes into a
crosshair when positioned in the
worksheet.
2. Drag as needed to create the button. Drag from the upper left
The button appears when you release corner of cell H4 to the
the mouse button, and the Assign lower right corner of cell
Macro dialog box opens. I4
3. Select the macro you want to assign to Click Chicago
the button.
The macro name appears in the Macro
name box.

Vicon Learning System Page 135


Lesson 9 - Creating a Macro Button Excel XP Level 4

Steps Practice Data


4. Select OK. Click OK
The Assign Macro dialog box closes.
5. Select the button text. Drag to select the Button
The button text is selected. 2 text
6. Type the desired button text. Type Open Chicago
The text appears on the button.
7. Click anywhere in the worksheet to Click anywhere in the
deselect the button. worksheet
The button is deselected.

Click the macro button to test it. Notice that the Chicago workbook opens.

Hide the Forms toolbar.


Close CHICAGO.XLS.

COPYING A MACRO BUTTON

δ Discussion
You can create new macro buttons quickly by copying existing ones. This option is
useful in adding several similar macro buttons to a worksheet. When you copy a
macro button, the pasted macro buttons will always be the same size and shape as the
copied macro button.

φ Step-by-Step
Copy a macro button.

If necessary, enable the macros.

Steps Practice Data


1. Hold [Ctrl] and drag the macro button Hold [Ctrl] and drag the
you want to copy to where you want top of the copy of the
the copy to appear. Open Chicago button to
A copy of the macro button appears the top of cell H6, directly
when you release the mouse button. below the copied macro
button

Page 136 Vicon Learning System


Excel XP Level 4 Lesson 9 - Creating a Macro Button

Steps Practice Data


2. Deselect the macro button copy. Click anywhere in the
The macro button copy is deselected. worksheet
3. Right-click the macro button copy. Right-click the Open
A shortcut menu appears. Chicago copy
4. Select the Assign Macro command. Click Assign Macro…
The Assign Macro dialog box opens.
7. Select the desired macro. Click NewYork
The macro name appears in the Macro
name box.
8. Select OK. Click OK
The Assign Macro dialog box closes.
9. Select the text you want to edit on the Double-click Chicago on
macro button copy. the Open Chicago copy
The text is selected.
10. Type the desired text. Type New York
The text appears on the macro button
copy.
11. Deselect the macro button copy. Click anywhere in the
The macro button is deselected. worksheet

Click the New York macro button to test it. Notice that the Newyork workbook
opens.
Close NEWYORK.XLS.

FORMATTING A MACRO BUTTON

δ Discussion
You can format text on a macro button in much the same way as you format text on a
worksheet. You can select the entire button and apply the same formats to all the
button text, or you can select individual characters in the button text to format.

ο To select a macro button for editing, hold the [Ctrl] key as


you click the macro button; otherwise, the macro attached to
the button runs when you click it.

Vicon Learning System Page 137


Lesson 9 - Creating a Macro Button Excel XP Level 4

φ Step-by-Step
Format a macro button.

If necessary, enable the macros.

Steps Practice Data


1. To format all the button text, hold Hold [Ctrl] and click the
[Ctrl] and click the macro button you Open Chicago button
want to format.
The macro button is selected.
2. Format the macro button text as
desired. Click
All the macro button text is formatted
accordingly.
3. Deselect the macro button. Click anywhere in the
The macro button is deselected. worksheet
4. To format selected macro button text, Hold [Ctrl] and click the
hold [Ctrl] and click the macro button Open Atlanta button
you want to format.
The macro button is selected.
5. Select the text you want to format. Double-click Atlanta
The text is selected.
6. Format the selected text as desired.
The text is formatted. Click
7. Deselect the macro button. Click anywhere in the
The macro button is deselected. worksheet

Practice the Concept: Bold the text on all macro buttons; then, italicize the city
names on each macro button.

MOVING/SIZING A MACRO BUTTON

δ Discussion
You can move or size a macro button in the same way that you move or size any
graphic object on a worksheet. In order to move or size a macro button, you must first
select it.

Page 138 Vicon Learning System


Excel XP Level 4 Lesson 9 - Creating a Macro Button

ο To select a macro button, hold the [Ctrl] key as you click it;
otherwise, the macro attached to the macro button runs when
you click it.

φ Step-by-Step
Move and size a macro button.

If necessary, enable the macros.

Steps Practice Data


1. To move a macro button, hold [Ctrl] Hold [Ctrl] and click the
and click the macro button to select it. Open Atlanta button
The macro button is selected.
2. Drag the selected macro button to the Drag the Open Atlanta
desired location on the worksheet. button below the Open
The macro button moves accordingly. New York button
3. Deselect the macro button. Click anywhere in the
The macro button is deselected. worksheet
4. To size a macro button, hold [Ctrl] Hold [Ctrl] and click the
and click the macro button to select it. Open Chicago button
The macro button is selected.
5. Drag any sizing handle in the desired Drag the top, center
direction. selection handle of the
The size of the macro button changes Open Chicago button to
accordingly. the bottom of row 2
6. Deselect the macro button. Click anywhere in the
The macro button is deselected. worksheet

DELETING A MACRO BUTTON

δ Discussion
You can delete any macro button you no longer need. Deleting unused macro buttons
protects you from accidentally running a macro that is outdated or no longer works
correctly.

Vicon Learning System Page 139


Lesson 9 - Creating a Macro Button Excel XP Level 4

When you delete a macro button, only the button is deleted; the attached macro
remains intact.

φ Step-by-Step
Delete a macro button.

If necessary, enable the macros.

Steps Practice Data


1. Hold [Ctrl] and click the macro button Hold [Ctrl] and click the
you want to delete. Open Chicago button
The macro button is selected.
2. Press [Delete]. Press [Delete]
The macro button is deleted.

Close CITY60.XLS.

Page 140 Vicon Learning System


Excel XP Level 4 Lesson 9 - Creating a Macro Button

EXERCISE
CREATING A MACRO BUTTON

ε Task
Create and work with macro buttons on a worksheet.

1. Open Exer85 and enable the macros.


2. Display the Forms toolbar.
3. Draw a macro button in the range M7:M8. Assign the Eastern
macro to the macro button and change the button text to Eastern
Sales. Then, italicize the button text.
4. Deselect the Eastern Sales button and click it to test it.
5. Drag to create a copy of the Eastern Sales button. Position its top,
left corner at the top, left corner of cell M3. Assign the ClearOutput
macro to the macro button and rename it Clear Report.
6. Deselect the Clear Report button and then click it to test it.
7. Move the Clear Report button below the Eastern Sales button,
aligning it to the top, left corner of cell M10.
8. Widen the Clear Report button to extend across both columns M
and N.

Vicon Learning System Page 141


Lesson 9 - Creating a Macro Button Excel XP Level 4

9. Delete both macro buttons.


10. Hide the Forms toolbar.
11. Close the workbook without saving it.

Page 142 Vicon Learning System


LESSON 10 -
USING WORKSHEET PROTECTION

In this lesson, you will learn how to:


• Unlock cells in a worksheet

• Protect a worksheet

• Unprotect a worksheet

• Create allow-editing ranges

• Delete allow-editing ranges

• Protect workbook windows

• Unprotect workbook windows

• Assign a password

• Open a password-protected file

• Remove a password

• Set manual calculation

• Reset automatic calculation

• Use the Document Recovery pane


Lesson 10 - Using Worksheet Protection Excel XP Level 4

UNLOCKING CELLS IN A WORKSHEET

δ Discussion
You can control access to a worksheet by locking or unlocking individual cells in it. If
worksheet protection is activated, you cannot change the contents of any locked cell.
If you want to allow changes to some cells, however, you can unlock those cells
before you activate worksheet protection.

As a rule, the cells you want to use for data entry are unlocked, and the cells that have
formulas in them are locked so that the formulas cannot be changed. For example, you
can lock all cells in a sales worksheet, except for those cells in which sales figures
need to be entered. You can also lock cells containing text.

Unlocking cells

ο Although cells are locked by default, this option has no effect


on a worksheet unless the worksheet is protected.

Page 144 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

φ Step-by-Step
From the Student Data directory, open PROJ3.XLS.
Unlock cells in a worksheet.

Steps Practice Data


1. Select the cells you want to unlock. Drag E3:E4
The cells are selected.
2. Select the Format menu. Click Format
The Format menu appears.
3. Select the Cells command. Click Cells...
The Format Cells dialog box opens.
4. Select the Protection tab. Click the Protection tab
The Protection page appears.
5. Deselect the Locked option. Click Locked to
The Locked option is deselected. deselect it
6. Select OK. Click OK
The Format Cells dialog box closes,
and the cells are unlocked.

Click anywhere in the worksheet to deselect the range.

PROTECTING A WORKSHEET

δ Discussion
Once you have unlocked cells, you can prevent changes to the rest of the worksheet
by protecting it. Protecting a worksheet prevents unauthorized or accidental changes
to formulas. For example, you can unlock only cells E3 and E4, leaving the rest of the
cells in the worksheet locked; if you then protect the worksheet, you will be able to
enter data in cells E3 and E4, but you will not be able to access any other cells.

You can assign an optional password to a protected worksheet. Passwords are case-
sensitive. A password is any combination of letters, numbers, symbols, and spaces,
and can be up to 255 characters long. For example, CLASS is a different password
than class.

You can select what features and functions of the worksheet you want to protect. For
example, you can allow users to select locked or unlocked cells, or format, insert, or
delete cells, columns, and rows.

Vicon Learning System Page 145


Lesson 10 - Using Worksheet Protection Excel XP Level 4

Protecting a worksheet

ο Many commands and toolbar buttons are not available in a


protected worksheet.

ο You can protect the worksheet structure from being deleted,


hidden, or moved or the worksheet window from being
hidden, moved, or resized by assigning a password to the
workbook in the Protect Workbook dialog box. To open the
Protect Workbook dialog box, select the Tools menu, point to
the Protection command, and then select the Protect
Workbook command.

ξ If you forget the password for a protected worksheet, you


cannot unprotect the worksheet.

φ Step-by-Step
Protect a worksheet.

If necessary, unlock cells E3 and E4.

Page 146 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Point to the Protection command. Point to Protection
The Protection submenu appears.
3. Select the Protect Sheet command. Click Protect Sheet...
The Protect Sheet dialog box opens
with the insertion point in the
Password to unprotect sheet box.
4. Type a password, if desired. Type class
Asterisks appear in the Password box
for each character you type.
5. Select OK. Click OK
If you typed a password, the Confirm
Password dialog box opens with the
insertion point in the Reenter
password to proceed. box.
6. Type the password again, if necessary. Type class
Asterisks appear in the Reenter
password to proceed. box for each
character you type.
7. Select OK, if necessary. Click OK
The Confirm Password and the Protect
Sheet dialog boxes close, and the
worksheet is protected.

Select cell D8 and type the word test. A Microsoft Excel warning box opens,
informing you that the cell is protected and you cannot edit it. Close the warning box.

Type 20 in cell E3 and 15 in cell E4. Notice that you can change the content of these
cells since they are unlocked.

UNPROTECTING A WORKSHEET

δ Discussion
You can unprotect a protected worksheet. If you used a password to protect the
worksheet, however, you must know the password to unprotect it.

After you have unprotected the worksheet, you can make changes to any cell in it.

Vicon Learning System Page 147


Lesson 10 - Using Worksheet Protection Excel XP Level 4

φ Step-by-Step
Unprotect a worksheet.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Point to the Protection command. Point to Protection
The Protection submenu appears.
3. Select the Unprotect Sheet command. Click Unprotect Sheet...
If a password was used to protect the
worksheet, the Unprotect Sheet dialog
box opens with the insertion point in
the Password box.
4. Type the required password, if Type class
necessary.
Asterisks appear in the Password box
for each character you type.
5. Select OK. Click OK
The Unprotect Sheet dialog box closes,
and the worksheet is unprotected.

Select cell D8 and type the word test. Notice that, since the worksheet is now
unprotected, you can type in the cell. Then, delete the word test.

CREATING ALLOW-EDITING RANGES

δ Discussion
If you want only certain users to be able to access specified cells in a worksheet, you
can identify those cells as an allow-editing range. You control access to this range by
first locking the cells in it and then assigning a password to it. After activating
worksheet protection, users are prompted for the assigned password when they select
any cell in the allow-editing range. If the correct password is entered, the range is
unlocked for editing; the allow-editing range is not locked again, however, until the
workbook is closed.

Page 148 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

The Allow Users to Edit Ranges dialog box

ο Remember to unlock the cells you want all users to be able to


edit before enabling worksheet protection.

ο You can select the allow-editing range before you open the
Allow Users to Edit Ranges dialog box; the range will then
appear in the New Range dialog box when it opens.

φ Step-by-Step
Create allow-editing ranges in a worksheet.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Point to the Protection command. Point to Protection
The Protection submenu appears.
3. Select the Allow Users to Edit Click Allow Users to Edit
Ranges command. Ranges...
The Allow Users to Edit Ranges dialog
box opens.
4. Select New. Click New...
The New Range dialog box opens.

Vicon Learning System Page 149


Lesson 10 - Using Worksheet Protection Excel XP Level 4

Steps Practice Data


5. Click the Collapse Dialog button in
Click Refers to cells
the Refers to cells box.
The New Range dialog box collapses.
6. Select the range in which you want to Drag B3:B5
allow editing.
The range is highlighted as you drag.
7. Click the Expand Dialog button.
Click
The New Range dialog box expands,
and the range reference appears in the
Refers to cells box.
8. Select the Range password box. Click in the Range
The insertion point appears in the password box
Range password box.
9. Type the desired password. Type actuals
Asterisks appear in the Range
password box for each character you
type.
10. Select OK. Click OK
The Confirm Password dialog box
opens with the insertion point in the
Reenter password to proceed. box.
11. Type the password again. Type actuals
Asterisks appear in the Reenter
password to proceed. box for each
character you type.
12. Select OK. Click OK
The Confirm Password and New
Range dialog boxes close, and the new
range name and reference appear in
the Allow Users to Edit Ranges dialog
box.
13. Select Protect Sheet. Click Protect Sheet...
The Protect Sheet dialog box opens
with the insertion point in the
Password to unprotect sheet box.
14. Type the desired password. Type class
Asterisks appear in the Password to
unprotect sheet box for each character
you type.

Page 150 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

Steps Practice Data


15. Select OK. Click OK
The Confirm Password dialog box
opens with the insertion point in the
Reenter password to proceed. box.
16. Type the password again. Type class
Asterisks appear in the Reenter
password to proceed. box for each
character you type.
17. Select OK. Click OK
The Confirm Password and Protect
Sheet dialog boxes close, and the
allow-editing range in the worksheet is
protected.

Select cell B4 and type 310853. The Unlock Range dialog box opens with the
insertion point in the Enter the password to change this cell box. Type the password
actuals and select OK to close the dialog box. Then, type 310853 in cell B4. Notice
that you can now edit cell B4 because the allow-editing range has been unlocked.

DELETING ALLOW-EDITING RANGES

δ Discussion
When a worksheet no longer needs an allow-editing range, it can be removed from the
worksheet. The worksheet must first be unprotected before you can remove the
unlocked range.

φ Step-by-Step
Delete allow-editing ranges.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Point to the Protection command. Point to Protection
The Protection submenu appears.

Vicon Learning System Page 151


Lesson 10 - Using Worksheet Protection Excel XP Level 4

Steps Practice Data


3. Select the Unprotect Sheet command. Click Unprotect Sheet...
The Unprotect Sheet dialog box opens
with the insertion point in the
Password box.
4. Type the required password. Type class
Asterisks appear in the Password box
for each character you type.
5. Select OK. Click OK
The Unprotect Sheet dialog box closes
and the password protection is
removed from the worksheet.
6. Select the Tools menu. Click Tools
The Tools menu appears.
7. Point to the Protection command. Point to Protection
The Protection submenu appears.
8. Select the Allow Users to Edit Click Allow Users to Edit
Ranges command. Ranges...
The Allow Users to Edit Ranges dialog
box opens.
9. Select the range you want to delete Click Range1 $B$3:$B$5
from the Ranges unlocked by a
password when sheet is protected list
box.
The range is selected.
10. Select Delete. Click Delete
The range is removed from the Ranges
unlocked by a password when sheet is
protected list box.
11. Select OK. Click OK
The Allow Users to Edit Ranges dialog
box closes.

PROTECTING WORKBOOK WINDOWS

δ Discussion
You can protect workbook windows. When you protect a workbook window, the
Minimize, Maximize, and Close buttons are removed; as a result, the window cannot

Page 152 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

be moved or resized. This option is useful if you have arranged the windows and want
to prevent them from being rearranged.

In addition to protecting a window, you can prevent structural changes to a workbook.


For example, if a workbook structure is protected, you cannot insert, delete, or move
worksheets contained in it.

You can assign an optional password. Passwords are case-sensitive. For example,
CLASS is a different password than class.

The Protect Workbook dialog box

ξ If you forget the password for a protected workbook, you


cannot unprotect the workbook.

φ Step-by-Step
Protect workbook windows.

Click the workbook Restore Window button to display the current workbook in a
window.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Point to the Protection command. Point to Protection
The Protection submenu appears.

Vicon Learning System Page 153


Lesson 10 - Using Worksheet Protection Excel XP Level 4

Steps Practice Data


3. Select the Protect Workbook Click Protect
command. Workbook...
The Protect Workbook dialog box
opens with the insertion point in the
Password (optional) box.
4. Type a password, if desired. Type class
Asterisks appear in the Password box
for each character you type.
5. Under Protect workbook for, select Click Windows
the desired options.
The options are selected.
6. Select OK. Click OK
If you typed a password, the Confirm
Password dialog box opens with the
insertion point in the Reenter
password to proceed. box.
7. Type the password again, if necessary. Type class
Asterisks appear in the Reenter
password to proceed. box for each
character you type.
8. Select OK. Click OK
The Confirm Password and Protect
Workbook dialog boxes close, and the
workbook window is protected.

Notice that the Minimize, Maximize, and Close buttons no longer appear on the
workbook window title bar. Try to resize the window by dragging. Notice that you are
unable to perform this task.

UNPROTECTING WORKBOOK WINDOWS

δ Discussion
When you unprotect a workbook window, the Maximize, Minimize, and Close
buttons are restored, and the window can be resized. You can also perform structural
changes (such as inserting, deleting, or moving worksheets) in an unprotected
workbook.

If a password has been used to protect a workbook, you must know the password to
unprotect it.

Page 154 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

ξ If you forget the password, you cannot unprotect the


workbook.

φ Step-by-Step
Unprotect workbook windows.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Point to the Protection command. Point to Protection
The Protection submenu appears.
3. Select the Unprotect Workbook Click Unprotect
command. Workbook...
If a password was used to protect the
workbook, the Unprotect Workbook
dialog box opens with the insertion
point in the Password box.
4. Type the required password, if Type class
necessary.
Asterisks appear in the Password box
for each character you type.
5. Select OK. Click OK
The Unprotect Workbook dialog box
closes, and the workbook window is no
longer protected.

Notice that the Minimize, Maximize, and Close buttons appear again on the
workbook window title bar. Maximize the window.

ASSIGNING A PASSWORD

δ Discussion
Passwords are used to protect a file. You can assign one password to open a file, and a
different password to modify a file. If you assign both types of passwords to a file,
only those users who know the open password can open the file, and only those users
who know both the open and modify passwords can save changes to it.

Vicon Learning System Page 155


Lesson 10 - Using Worksheet Protection Excel XP Level 4

Passwords are case-sensitive and can be any combination of letters, numbers,


symbols, and spaces, up to 15 characters long. After a password has been assigned,
you will be prompted for the password each time you open the document and/or each
time you try to save it, depending on the type of password.

Passwords are often assigned to files that contain sensitive data, such as salaries or
bonuses. They can also be used to secure files stored on a network.

Assigning a password

ο You can also use the Security page in the Options dialog box
to assign a password.

ξ If you forget an assigned password, you cannot open and/or


save the file.

φ Step-by-Step
Assign a password to a file.

Steps Practice Data


1. Select the File menu. Click File
The File menu appears.
2. Select the Save As command. Click Save As...
The Save As dialog box opens.

Page 156 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

Steps Practice Data


3. Select the Tools menu in the Save As Click Tools
dialog box.
The Tools menu appears.
4. Select the General Options command. Click General Options...
The Save Options dialog box opens
with the insertion point in the
Password to open box.
5. Type the desired password. Type class
Asterisks appear in the Password to
open box for each character you type.
6. Select OK. Click OK
The Confirm Password dialog box
opens with the insertion point in the
Reenter password to proceed. box.
7. Type the password again. Type class
Asterisks appear in the Reenter
password to proceed. box for each
character you type.
8. Select OK. Click OK
The Confirm Password and Save
Options dialog boxes close.
9. Select Save. Click Save
A Microsoft Excel warning box opens,
prompting you to overwrite the
existing file.
10. Select Yes. Click Yes
The Microsoft Excel warning box and
the Save As dialog box close, and the
file is saved with the assigned
password.

Close PROJ3.XLS.

OPENING A PASSWORD-PROTECTED FILE

δ Discussion
Once a file is password-protected, you must know the password to open it. Whenever
you try to open a password-protected file, the Password dialog box prompts you to
enter the assigned password.

Vicon Learning System Page 157


Lesson 10 - Using Worksheet Protection Excel XP Level 4

The Password dialog box

ξ If you forget the assigned password, you cannot open the file.

φ Step-by-Step
Open a password-protected file.

Steps Practice Data


1. Click the Open button on the
Standard toolbar. Click
The Open dialog box opens.
2. Select the Look in list. Click Look in
A list of available drives appears.
3. Select the drive where the file is Click the student data
stored. drive, if necessary
A list of available folders appears.
4. Open the folder where the file is Double-click the student
stored. data folder, if necessary
A list of available folders and files
appears.
5. Select the file you want to open. Click Proj4 or the file
The file is selected. indicated by your
instructor
6. Select Open. Click Open
The Open dialog box closes, and the
Password dialog box opens with the
insertion point in the Password box.
7. Type the required password. Type class
Asterisks appear in the Password box
for each character you type.

Page 158 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

Steps Practice Data


8. Select OK. Click OK
The Password dialog box closes, and
the file opens.

REMOVING A PASSWORD

δ Discussion
If a password is no longer needed, you can remove it from a file. You can then open
the file at any time without a password.

When you remove a password, you must save the file to replace the protected version.

ο You can also use the Security page in the Options dialog box
to remove a password.

φ Step-by-Step
Remove a password from a file.

If necessary, type class in the Password dialog box to open the file.

Steps Practice Data


1. Select the File menu. Click File
The File menu appears.
2. Select the Save As command. Click Save As...
The Save As dialog box opens.
3. Select the Tools menu in the Save As Click Tools
dialog box.
The Tools menu appears.
4. Select the General Options command. Click General Options...
The Save Options dialog box opens
with the asterisks in the Password to
open box selected.

Vicon Learning System Page 159


Lesson 10 - Using Worksheet Protection Excel XP Level 4

Steps Practice Data


5. Press [Delete]. Press [Delete]
The asterisks in the Password to open
box are deleted.
6. Select OK. Click OK
The Save Options dialog box closes.
7. Select Save. Click Save
A Microsoft Excel warning box opens,
prompting you to overwrite the
existing file.
8. Select Yes. Click Yes
The Microsoft Excel warning box and
the Save As dialog box close, and the
password is removed from the file.

SETTING MANUAL CALCULATION

δ Discussion
When you change any number in a worksheet, all formulas that refer to that number
are automatically recalculated. You can configure the worksheet to recalculate
manually instead. Manual recalculation allows you to change numbers as needed and
then recalculate the worksheet only when desired. This option can save time when you
are working in large, complex worksheets.

When recalculation is set to manual, the Calculate indicator appears on the status bar
when values have changed and formulas need to be recalculated. If the Calculate
indicator appears on the status bar, the worksheet figures may not be accurate. For this
reason, it is a good idea to always recalculate before you print the worksheet.

Calculation options are system settings rather than workbook settings. Consequently,
once you have enabled manual calculation, all worksheets will have to be manually
recalculated until you change the calculation back to automatic.

Page 160 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

Setting manual calculation

ο Even if calculation is set to manual, worksheets will


automatically recalculate each time you save them, if the
Recalculate before save option is selected on the Calculation
page in the Options dialog box.

ο You can recalculate all open workbooks by selecting the Calc


Now button on the Calculation page in the Options dialog
box or pressing the [F9] key. To recalculate only the current
worksheet, select the Calc Sheet button on the Calculation
page in the Options dialog box.

φ Step-by-Step
Set manual calculation.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Select the Options command. Click Options...
The Options dialog box opens.
3. Select the Calculation tab. Click the Calculation tab
The Calculation page appears.

Vicon Learning System Page 161


Lesson 10 - Using Worksheet Protection Excel XP Level 4

Steps Practice Data


4. Under Calculation, select the Manual Click Manual
option.
The Manual option is selected.
5. Select OK. Click OK
The Options dialog box closes, and
calculation is set to manual.

Select cell E3, type 25, and press [Enter]. Notice that the formulas do not recalculate
and that the Calculate indicator appears on the status bar.

Press [F9] to recalculate the workbook. Notice that cell B8 changes from 2,140,708 to
2,229,904, cell B10 changes from 1,784,377 to 1,873,573, and the Calculate indicator
no longer appears on the status bar.

RESETTING AUTOMATIC CALCULATION

δ Discussion
Calculation options are system settings rather than workbook settings. As a result, if
you select manual recalculation for one workbook, you will have to manually
recalculate all workbooks until you change the calculation back to automatic.

φ Step-by-Step
Reset automatic calculation.

Steps Practice Data


1. Select the Tools menu. Click Tools
The Tools menu appears.
2. Select the Options command. Click Options…
The Options dialog box opens.
3. Select the Calculation tab. Click the Calculation tab,
The Calculation page appears. if necessary
4. Under Calculation, select the Click Automatic
Automatic option.
The Automatic option is selected.

Page 162 Vicon Learning System


Excel XP Level 4 Lesson 10 - Using Worksheet Protection

Steps Practice Data


5. Select OK. Click OK
The Options dialog box closes, and
automatic calculation is reset.

Select cell E3, type 15, and press [Enter]. Notice that the formulas recalculate
automatically.
Close PROJ4.XLS.

USING THE DOCUMENT RECOVERY PANE

δ Discussion
Office XP provides a file recovery feature that can recover data lost when an error
prevents the normal saving and closing of a file (such as when your computer
suddenly crashes or loses power). The next time you start Excel after a system halt,
the Document Recovery pane appears on the left side of the application window,
with a list of all workbooks that were open when the error occurred. For each
workbook, the task pane shows the file name, as well as when you last saved the
workbook. If the workbook is marked as recovered, it is probably a more recent
version of the original workbook than the last saved version.

Right-clicking a workbook in the Document Recovery pane displays a list of


available recovery options. The Open option opens the recovered file. The Save As
option allows you to save the recovered file with a new name; if you save the file with
the same name, the original file is overwritten. If the workbook is marked as
recovered, you can select the Delete option to delete the recovered file or the Show
Repairs option to view the repairs that were made to the file.

ο You can also open a file by clicking it in the Document


Recovery pane.

Vicon Learning System Page 163


Lesson 10 - Using Worksheet Protection Excel XP Level 4

EXERCISE
USING WORKSHEET PROTECTION

ε Task
Use worksheet protection.

1. Open Protect.
2. Unlock the range D6:D12.
3. Protect the worksheet, assigning a password of protect.
4. Change cell D11 to 3. Change cell E11 to 2. Then, close the
Microsoft Excel message box.
5. Unprotect the worksheet. Then, change the type of time in cell E11
to 2.
6. Select the range F6:F12 and make it an allow-editing range. Assign
the password special to the allow-editing range and the password
class to the worksheet.
7. Change the rate in F12 from 5.50 to 6.00. Then, delete the unlocked
range. (Hint: First unprotect the worksheet.)
8. Protect both the workbook structure and windows; assign a password
of workbook. Notice that the window buttons for the workbook are
no longer available.
9. Unprotect the workbook.
10. Assign a password to open the workbook; type save as the password.
Then, close the workbook.
11. Reopen Protect. Notice that you must enter the assigned password.
12. Set the calculation to manual.
13. Select cell D6 and type 7. Then, recalculate the worksheet manually.
Notice that cell G6 is updated.
14. Reset the calculation to automatic.
15. Remove the password from the workbook.
16. Close the workbook without saving it.

Page 164 Vicon Learning System


INDEX

3-D ranges
creating, 33
using in formulas, 34, 35
Absolute references
using in macros, 90
Allow-editing ranges
creating, 148, 149
deleting, 151
Arguments
using in functions, 2
Buttons
adding the Custom Button to a toolbar, 116, 117
adding to a toolbar, 115, 116
assigning macros to, 118
changing the image, 119
displaying button text and image, 120, 121
removing from a toolbar, 115, 116
Calculation
automatic, 162
manual, 160, 161
resetting automatic, 162
setting manual, 160, 161
Cells
unlocking in a worksheet, 144, 145
Comments
entering for macros, 101, 102
Data
limiting the precision of numbers, 60, 61
Data tables, 66
creating one-variable, 67, 68
creating two-variable, 69, 70
placing formulas in, 66
Date functions, 10, 11
Dates
formatting, 13, 14
Files
recovering, 163
Financial functions, 3, 4
Formulas
3-D, 31, 32
revising, 15
using 3-D range names, 34, 35
using range names, 24, 25
Functions
date, 10, 11
financial, 3, 4

Vicon Learning System Page 165


HLOOKUP, 40, 43, 45
IF, 6, 8, 46, 48
ISERROR, 52, 53
logical, 6
nested IF, 49, 50
revising, 15
ROUND, 57, 59
using AND conditions with IF, 54, 55
using arguments in, 2
using lookup, 40
using OR conditions with IF, 56
VLOOKUP, 40, 42
IF functions, 6, 8
Logical functions, 6
Macro buttons, 134
copying, 136
creating, 134, 135
deleting, 139, 140
formatting, 137, 138
moving, 138, 139
sizing, 138, 139
Macros
assigning a shortcut key, 88, 89
assigning to a button, 118
assigning to a menu, 92, 93
copying commands, 103
defining, 74
deleting, 95
editing commands, 104, 105
entering comments, 101, 102
opening a workbook containing, 74, 75
opening the Visual Basic Editor window, 80, 82
recording, 86
removing custom menu items, 94
running, 76, 77
running from the Code window, 108
typing commands, 106, 107
using a shortcut key, 78, 79
using absolute references, 90
using relative references, 90
using the Visual Basic Editor window, 82
using the Visual Basic toolbar, 79, 80
writing new, 100, 101
Menus
adding custom commands, 127, 128
assigning macros to, 92, 93
creating custom, 125, 126
removing custom menu items, 94
Modules, 74
Numbers
limiting precision, 60, 61

Page 166 Vicon Learning System


rounding, 57, 59
Passwords
adding to a worksheet, 145, 146
assigning, 155, 156
opening a password-protected file, 157, 158
protecting workbook windows, 152, 153
removing, 159
unprotecting a worksheet, 147, 148
unprotecting workbook windows, 154, 155
Procedures, 74
Range names, 20
3-D, 33, 35
applying, 27, 28
assigning, 22, 23
creating, 22, 23
creating from headings, 25, 26
deleting, 29, 30
in 3-D formulas, 31, 32
jumping to, 20, 21
using in formulas, 24, 25, 34, 35
Ranges
unlocking for editing, 148, 149
Relative references
using in macros, 90
Shortcut keys
assigning to macros, 88, 89
using to run macros, 78, 79
Task pane
Document Recovery, 163
Toolbars
adding buttons, 115, 116
adding the Custom Button, 116, 117
assigning a macro to a button, 118
attaching custom to a workbook, 122, 123
changing a button image, 119
creating custom, 114
deleting custom, 123, 124
displaying button text and image, 120, 121
removing buttons, 115, 116
Visual Basic Editor, 74
opening the window, 80, 82
using the window, 82
Visual Basic toolbar
using, 79, 80
Windows
protecting workbook, 152, 153
unprotecting workbook, 154, 155
Workbooks
attaching custom toolbars, 122, 123
opening those containing macros, 74, 75
Worksheets

Vicon Learning System Page 167


protecting, 145, 146
unlocking a range for editing, 148, 149
unlocking cells, 144, 145
unprotecting, 147, 148

Page 168 Vicon Learning System

You might also like