﻿

# EXCEL tutorial route optimization PDF

Télécharger EXCEL tutorial route optimization PDF

★★★★★★★★★★3.5 étoiles sur 5 basé sur 1 votes.
Votez ce document:

### Télécharger aussi :

Microsoft Excel

CBT Infotech Pvt. Ltd.

1st floor, Canteen Building,

Mumbai – 400 072  2852 6138/39

The structure or order of the elements in a formula determine the final result of the calculation. Formulas in Microsoft Excel follow a specific syntax, or order, that includes an equal sign (=) followed by the elements to be calculated (the operands), which are separated by calculation operators. Each operand can be a value that does not change (a constant value), a cell or range reference, a label, a name, or a worksheet function.

Excel performs the operations from left to right — according to the order of operator precedence— starting with the equal sign (=). You can control the order of calculation by using parentheses to group operations that should be performed first. For example, the following formula produces 11 because Excel calculates multiplication before addition. The formula multiplies 2 by 3 and then adds 5 to the result.

=5+2*3

In contrast, if you use parentheses to change the syntax, Excel adds 5 and 2 together and then multiplies the result by 3 to produce 21. =(5+2)*3

Click the cell in which you want to enter the formula.

Type = (an equal sign).

If you click Edit Formula or Paste Function ,Microsoft Excel inserts an equal sign for you.

Enter the formula.

Press ENTER.

You can enter the same formula into a range of cells by selecting the range first, typing the formula, and then pressing CTRL+ENTER.

You can also enter a formula into a range of cells by copying a formula from another cell.

Operators specify the type of calculation that you want to perform on the elements of a formula. Microsoft Excel includes four different types of calculation operators: arithmetic, comparison, text, and reference.Arithmetic operators   To perform basic mathematical operations such as addition, subtraction, or multiplication; combine numbers; and produce numeric results, use the following arithmetic operators.

Comparison operators   You can compare two values with the following operators. When two values are compared by using these operators, the result is a logical value,

 Arithmetic operator Meaning Example + (plus sign) Addition 3+3 – (minus sign) Subtraction 3–1 Negation –1 * (asterisk) Multiplication 3*3 / (forward slash) Division =3/45 % (percent sign) Percent 0.2 ^ (caret) Exponentiation 3^2 (the same as 3*3)

either TRUE or FALSE.

 Comparison operator Meaning Example = (equal sign) Equal to A1=B1 > (greater than sign) Greater than A1>B1 < (less than sign) Less than A1= (greater than or equal to sign) Greater than or equal to A1>=B1 <= (less than or equal to sign) Less than or equal to A1<=B1 <> (not equal to sign) Not equal to A1<>B1

Text concatenation operator   Use the ampersand (&) to join, or concatenate, one or more text strings to produce a single piece of text.

Reference operators   Combine ranges of cells for calculations with the following operators.

 Reference operator Meaning Example : (colon) Range operator, which produces one reference to all the cells between two references, including the two references B5:B15 , (comma) Union operator, which combines multiple references into one reference SUM(B5:B15,D5:D15)

1.  If you combine several operators in a single formula, Microsoft Excel performs the operations in the order shown in the following table.

2.  If a formula contains operators with the same precedence — for example, if a formula contains both a multiplication and division operator — Excel evaluates the operators from left to right.

3.  To change the order of evaluation, enclose the part of the formula to be calculated first in parentheses.

 Operator Description : (colon) Reference operators (single space) , (comma) – Negation (as in –1) % Percent ^ Exponentiation * and / Multiplication and division + and – Addition and subtraction & Connects two strings of text (concatenation) = < > <= >= <> Comparison

Microsoft Excel stores dates as sequential numbers known as serial values. Excel stores times as decimal fractions because time is considered a portion of a day. Dates and times are values and, therefore, can be added, subtracted, and included in other calculations. For example, to determine the difference between two dates, you can subtract one date from the other. You can view a date as a serial value and a time as a decimal fraction by changing the format of the cell that contains the date or time to General format.

Excel supports two date systems: the 1900 and 1904 date systems. The default date system for Microsoft Excel for Windows is 1900. To change to the 1904 date system, click Options on the Tools menu, click the Calculation tab, and then select the 1904 date system check box.

The following table shows the first date and the last date for each date system and the serial value associated with each date.

 Date system First date Last date 1900 January 1, 1900 December 31, 9999 1904 January 2, 1904 December 31, 9999

Notes: Two-digit years   when you enter a date in a cell and you enter only two digits for the year, Excel interprets the year as follows:

The years 2000 through 2029 if you type 00 through 29 for the year. For example, if you type 5/28/19, Excel assumes the date is May 28, 2019.

The years 1930 through 1999 if you type 30 through 99 for the year. For example, if you type 5/28/98, Excel assumes the date is May 28, 1998.

To switch between displaying formulas and their values for all formulas on a worksheet, press CTRL+` (single left quotation mark).

For example:

•   Click the cell that contains the formula you want to edit.

•   If the cell contains a hyperlink, click a cell next to the cell you want to edit, and then use an arrow key to select the cell with the formula you want to edit.

•   In the formula bar, make the changes to the formula.

•   If you want to edit a function in the formula, edit the arguments in the function.  • Press ENTER.

•   If the formula is an array formula, press CTRL+SHIFT+ENTER.

Caution:  When you replace a formula with its value, Microsoft Excel permanently removes the formula. If you accidentally replace a formula with a value and want to restore the formula, click Undo immediately after you enter or paste the value.

•   Select the cell that contains the formula.

•   If the formula is an array formula, select the range that contains the array formula.  • Click Copy

•   On the Edit menu, click Paste Special.

•   Under Paste, click Values.

•   Click the cell that contains the formula.

•   In the formula bar, select the portion of the formula you want to replace with its calculated value. When you select the part of the formula you want to replace, make sure to include the entire operand.

•   or press F2 for entire formula .

•   For example, if you select a function, you must select the entire function name, the opening parenthesis, the arguments, and the closing parenthesis.

•   To calculate the selected portion, press F9.

•   To replace the selected portion of the formula with its calculated value, press ENTER.

•   If the formula is an array formula, press CTRL+SHIFT+ENTER.

•   To restore the original formula, press ESC.

Relative references   When you create a formula, references to cells or ranges are usually based on their position relative to the cell that contains the formula. In the following example, cell B6 contains the formula =A5; Microsoft Excel finds the value one cell above and one cell to the left of B6. This is known as a relative reference.  When you copy a formula that uses relative references, Excel automatically adjusts the references in the pasted formula to refer to different cells relative to the position of the formula. In the following example, the formula in cell B6, =A5, which is one cell above and to the left of B6, has been copied to cell B7. Excel has adjusted the formula in cell B7 to =A6, which refers to the cell that is one cell above and to the left of cell B7.

Absolute references   If you don't want Excel to adjust references when you copy a formula to a different cell, use an absolute reference. For example, if your formula multiplies cell A5 with cell C1 (=A5*C1) and you copy the formula to another cell, Excel will adjust both references. You can create an absolute reference to cell C1 by placing a dollar sign (\$) before the parts of the reference that do not change. To create an absolute reference to cell C1, for example, add dollar signs to the formula as follows:

=A5*\$C\$1

Switching between relative and absolute references   If you created a formula and want to change relative references to absolute (and vice versa), select the cell that contains the formula. In the formula bar, select the reference you want to change and then press F4. Each time you press F4, Excel toggles through the combinations: absolute column and absolute row (for example, \$C\$1); relative column and absolute row (C\$1); absolute column and relative row (\$C1); and relative column and relative row (C1). For example, if you select the address \$A\$1 in a formula and press F4, the reference becomes A\$1. Press F4 again and the reference becomes \$A1, and so on.

You can use 3-D references to refer to cells on other sheets, to define names, and to create formulas by using the following functions: SUM, AVERAGE, AVERAGEA, COUNT, COUNTA, MAX, MAXA, MIN, MINA, PRODUCT, STDEV, STDEVA, STDEVP, STDEVPA, VAR, VARA, VARP, and VARPA.

•   Click the cell where you want to enter the function.

•   Type = (an equal sign), enter the name of the function, and then type an opening parenthesis.

•   Click the tab for the first worksheet to be referenced.

•   Hold down SHIFT and click the tab for the last worksheet to be referenced.

•   Select the cell or range of cells to be referenced.

•   Complete the formula.

Example: =SUM (Sheet1: Sheet3!B20:C25)

Worksheets often have labels at the top of each column and to the left of each row that describe the data within the worksheet. You can use these labels within formulas when you want to refer to the related data. You can also create descriptive names that are not labels on the worksheet to represent cells, ranges of cells, formulas, or constants.

Important :  By default, Microsoft Excel does not recognize labels in formulas. To use labels in formulas, click Tools :OptionsCalculation tab. Under Workbook options, select the Accept labels in formulas check box.

Use labels to represent cells   When you create a formula that refers to data in a worksheet, you can use the column and row labels in the worksheet to refer to the data. For example, the following example contains columns labeled Product 1, Product 2, and Product 3. To calculate the total value for the Product 1 column, use the formula =SUM (Product 1).

Or if you need to refer to the Product 3 amount for the East division (that is, the value 110.00), you can use the formula =Product 3 East.

The space in the formula between "Product 3" and "East" is the intersection operator. This operator designates that Microsoft Excel should find and return the value in the cell at the intersection of the row labeled East and the column labeled Product 3.

Define names to represent cells   If your data does not have labels or if you have information stored on one worksheet that you want to use on other sheets, you can create a name that describes the cell or range. A descriptive name in a formula can make it easier to understand the purpose of the formula. For example, the formula =SUM(FirstQuarterSales) might be easier to identify than =SUM(Sales!C20:C30). In this example, the name FirstQuarterSales represents the range C20:C30 on the worksheet named Sales.

Names are available to any sheet. For example, if the name ProjectedSales refers to the range A20:A30 on the first worksheet in a workbook, you can use the name ProjectedSales on any other sheet in the same workbook to refer to range A20:A30 on the first worksheet. Names can also be used to represent formulas or values that do not change (constants). For example, you can use the name Sales Tax to represent the sales tax amount (such as 6.2 percent) applied to sales transactions.

Specifying labels   When you select cells in labeled ranges to create formulas, Microsoft Excel can insert the labels in place of cell references in your formulas.

Using labels can make it easier to see how a formula is constructed. You can use the Label Ranges dialog box (Insert menu, Name submenu, Label command) to specify the ranges that contain column and row labels on your worksheet.

Using dates as labels   When you label a range by using the Label Ranges dialog box and the range contains a year or date as a label, Excel defines the date as a label by placing single quotation marks around the label when you type the label in a formula. For example, suppose your worksheet contains the labels 1996 and 1997 and you have specified these labels by using the Label Ranges dialog box. When you type the formula =SUM(1997), Excel automatically updates the formula to =SUM('1997').

Tip   If you label a list by using the Label command and then zoom the view of the worksheet to 39 percent or less, Excel adds a blue border around the labels you have specified with the Label Ranges command on the worksheet. The blue border does not print and is not displayed when you zoom the worksheet view above 39 percent.

•   Select the cell, range of cells, or nonadjacent selections that you want to name.

•   Click the Name box at the left end of the formula bar.

•   Type the name for the cells.

•   Press ENTER.

Note   You cannot name a cell while you are changing the contents of the cell.

On the Insert menu, point to Name, and then click Define.

In the Names in workbook box, type the name.

If the Refers to box contains a reference, select the equal sign (=) and the reference and press BACKSPACE.

In the Refers to box, type = (an equal sign).

Click the tab for the first worksheet to be referenced.

Hold down SHIFT and click the tab for the last worksheet to be referenced. Select the cell or range of cells to be referenced.

On the Insert menu, point to Name, and then click Define.

In the Names in workbook box, enter the name for the formula.

In the Refers to box, type = (an equal sign), followed by the formula or the constant value.

On the Insert menu, point to Name, and then click Define.

In the Names in workbook list, click the name whose reference you want to check.

The Refers to box displays the reference, formula, or constant  the name represents.

Select the range that contains formulas in which you want to replace references with names.

To change the references to names in all formulas on the worksheet, select a single cell.

On the Insert menu, point to Name, and then click Apply.  In the Apply names box, click one or more names.

On the Insert menu, point to Name, and then click Define.

In the Names in workbook box, click the name whose cell reference, formula, or constant you want to change.

In the Refers to box, change the reference, formula, or constant.

## Change the name for a reference, formula, or constant

On the Insert menu, point to Name, and then click Define.

In the Names in workbook list, click the name you want to change.

In the Names in workbook box, select the name.

Type the new name for the reference, and then click Add.

To delete the original name, click the original name, and then click Delete.

When you define a name that refers to a cell or range of cells in another workbook, you create a link known as an external reference. When you do this procedure, make sure the workbook you want to refer to is open and that it has been saved.

In the workbook in which you want to create the external reference, point to Name on the Insert menu, and then click Define.

In the Names in workbook box, enter the name for the external reference.

If the Refers to box contains a reference, select the equal sign (=) and the reference and press BACKSPACE.

Activate the workbook that contains the cell you want to refer to by clicking the name of the workbook on the Window menu.

Select the cell or range of cells you want to refer to.

In the Define Name dialog box, click Add.

An array formula can perform multiple calculations and then return either a single result or multiple results. Array formulas act on two or more sets of values known as array arguments. Each array argument must have the same number of rows and columns. You create array formulas in the same way that you create other formulas, except you press CTRL+SHIFT+ENTER to enter the formula.

 country sales sum figures in SALES column  only if it has "brazil" on the  left column COUNTRY europe 10 brazil 20 denmark 30 europe 10 brazil 20 denmark 30 europe 10 =SUM(IF(B3:B20="Brazil",C3: C20)) brazil 20

Calculate a single result   Sometimes Microsoft Excel must perform several calculations to generate a single result. For example, the above worksheet shows that a company has regional offices in Europe, Brazil and find the total sales for Brazil you would need to use an array formula.

Cell contains the array formula, which finds the cells in the range that contain the text "Brazil" and then sums the corresponding cells in the neighboring column

Calculate multiple results   To calculate multiple results with an array formula, you must enter the array into a range of cells that has the same number of rows and columns as the array arguments. In the following example, given a series of three sales figures (in row 5) for a series temperatures the TREND function determines the straight-line values for the sales figures. To display all of the results of the formula, it is entered into cells .

When you enter the formula as shown in figure as an array formula, it produces three separate results, based on the three sales figures and the three months.

You can share data stored on different worksheets and workbooks by using linking, or external references. Linking is especially useful when it is not practical to keep large worksheet models together in the same workbook.

Link to another worksheet in the same workbook In the following example, the AVERAGE worksheet function calculates the average value for the range B1:B10 on the worksheet named Marketing in the same workbook.

=A7+'[excel exercise for bombay ]Sheet1'!\$C\$11 for example .

Link to a worksheet in another workbook   Not only can you create links between different worksheets, but you can also construct hierarchies of linked workbooks. For example, a group of sales offices may track data in individual workbooks; the data is then rolled into a workbook that summarizes the data at the district level, which is then rolled into a workbook that summarizes data at a regional level.

Note  : When cells that supply data to a link are changed, Excel updates the link automatically only if the workbook containing the link is open. If you do link workbooks, be sure to update the dependent workbooks when you update or change values in the source workbooks. If a dependent workbook is open when you change data in the source workbook, Excel updates the dependent workbook automatically. If the dependent workbook is not open, you can update the links manually.

Excel displays formulas with links to other workbooks two ways, depending on whether the source workbook — the one that supplies data to a formula — is open or closed. When the source is open, the link includes the workbook name in square brackets, followed by the worksheet name, an exclamation point ( ! ), and the cells that the formula depends on. When the source is closed, the link includes the entire path. For Example:

=A7+'[excel exercise for bombay ]Sheet1'!\$C\$11

=A7+'C:\My documents\[excel exercise for bombay ]Sheet1'!\$C\$11

Note:  If the name of the other worksheet or workbook contains nonalphabetic characters, you must enclose the name (or the path) within single quotation marks.

If you are linking to a new workbook, save the new workbook before creating the link.

In the workbook that will contain the formula, select the cell in which you want to enter the external reference.

If you are creating a new formula, type = (an equal sign).

If you are entering the external reference elsewhere in the formula, type the operator or function that you want to precede the external reference.

If you want to create a link to another worksheet in the active workbook, click the worksheet that contains the cells you want to link to.

If you want to create a link to a worksheet in another workbook, switch to the other workbook, by using Windows Menu and then click the worksheet that contains the cells you want to link to.

Select the cells you want to link to.

Complete the formula. When you finish entering the formula, press ENTER.

When you define a name that refers to a cell or range of cells in another workbook, you create a link known as an external reference. When you do this procedure, make sure the workbook you want to refer to is open and that it has been saved.

In the workbook in which you want to create the external reference, point to Name on the Insert menu, and then click Define.

In the Names in workbook box, enter the name for the external reference.

If the Refers to box contains a reference, select the equal sign (=) and the reference and press BACKSPACE.

Activate the workbook that contains the cell you want to refer to by clicking the name of the workbook on the Window menu.

Select the cell or range of cells you want to refer to. In the Define Name dialog box, click Add.

Switch to the workbook that contains the formula with the external reference.

In the Source file box, click the name of the workbook you want to open. Click Open Source.

Microsoft Excel provides tools that help you track down problems on your worksheets. For example, the value you see in a cell may be the result of a formula, or it may be used by a formula that produces an incorrect result. The auditing commands graphically display, or trace, the relationships between cells and formulas with tracer arrows. When you audit a worksheet, you can trace the precedents (the cells that provide data to a specific cell) or you can trace the dependents (the cells that depend on the value in a specific cell.

One blue tracer arrow shows that cells D9 through D11 are precedents of cell B5, which contains the formula =SUM(D9:D11). The other blue tracer arrows show that cells C9, C10, and C11 are precedents of B6, which contains the formula =C9+C10+C11. Notice that D9:D11, because it's a range in the formula, is traced as a group.

Display the Auditing toolbar by pointing to Auditing on the Tools menu and then clicking Show Auditing Toolbar.

Before you use the Auditing toolbar, make sure Show all or Show placeholders is selected under Objects on the View tab in the Options dialog box (Tools menu).

Click the cell that displays the error.

Click Trace Error

Display the Auditing toolbar by pointing to Auditing on the Tools menu and then clicking Show Auditing Toolbar.

Before you use the Auditing toolbar, make sure Show all or Show placeholders is selected under Objects on the View tab in the Options dialog box (Tools menu).  Select the cell that contains the formula for which you want to find precedent cells. To display a tracer arrow to each cell that directly provides data to the active cell, click Trace Precedents on the Auditing toolbar.

To identify the next level of cells that provide data to the active cell, click Trace Precedents again.

Notes:  Blue arrows show cells in the same worksheet that provide data to the formula in the selected cell. Red arrows show cells that cause errors. If the selected cell contains a reference to another worksheet or workbook, a black arrow points from a worksheet icon to the selected cell.

To select the cell at the other end of an arrow, double-click the arrow. To select a precedent cell in another worksheet or workbook, double-click the black arrow and then double-click the reference you want in the Go to list.

If the precedent cell is in another workbook, that workbook must be open before you can select the precedent cell.

Display the Auditing toolbar by pointing to Auditing on the Tools menu and then clicking Show Auditing Toolbar.

Before you use the Auditing toolbar, make sure Show all or Show placeholders is selected under Objects on the View tab in the Options dialog box (Tools menu).  Select the cell for which you want to identify the dependent cells.

To display a tracer arrow to each cell that is dependent on the active cell, click Trace Dependents on the Auditing toolbar.

To identify the next level of cells that depend on the active cell, click Trace ependents again.

Blue arrows show cells in the same worksheet that are dependent on the selected cell. Red arrows show cells that cause errors. If a cell on another worksheet or workbook references the selected cell, a black arrow points from the selected cell to a worksheet icon

If the dependent cell is in another workbook, that workbook must be open before Excel can trace the dependent cell.

Display the Auditing toolbar by pointing to Auditing on the Tools menu and then clicking Show Auditing Toolbar.

Before you use the Auditing toolbar, make sure Show all or Show placeholders is selected under Objects on the View tab in the Options dialog box (Tools menu).

To remove tracer arrows one level at a time, starting with the dependent cell farthest away from the active cell, click Remove Dependent Arrows. To remove another level of tracer arrows, click the button again.

To remove tracer arrows one level at a time, starting with the precedent cell farthest away from the active cell, click Remove Precedent Arrows. To remove another level of tracer arrows, click the button again. To remove all tracer arrows on the worksheet, click Remove All Arrows on the Auditing toolbar.

Open the workbook that contains the formula with the external reference that refers to the renamed or moved workbook.

In the Source file box, click the name of the workbook for which you want to update the reference.

Click Change Source.

In the Change Links dialog box, click the workbook you want to refer to.

Functions are predefined formulas that perform calculations by using specific values, called arguments, in a particular order, or structure. For example, the SUM function adds values or ranges of cells, and the PMT function calculates the loan payments based on an interest rate, the length of the loan, and the principal amount of the loan. Arguments Arguments can be numbers, text, logical values such as TRUE or FALSE, arrays, error values such as #N/A, or cell references. The argument you designate must produce a valid value for that argument. Arguments can also be constants, formulas, or other functions. For more information about using a function as an argument for another function, also known as nesting functions, click.

Structure   The structure of a function begins with the function name, followed by an opening parenthesis, the arguments for the function separated by commas, and a closing parenthesis. If the function starts a formula, type an equal sign (=) before the function name. As you create a formula that contains a function, the Formula Palette will assist you.

TODAY

Returns the serial number of the current date. The serial number is the date-time code used by Microsoft Excel for date and time calculations. For more information about serial numbers. Syntax

TODAY( )

NOW

Returns the serial number of the current date and time.

Syntax

NOW( )

Remarks

Microsoft Excel stores dates as sequential serial numbers so that it can perform calculations on them. Excel stores January 1, 1900, as serial number 1 if your workbook uses the 1900 date system. If your workbook uses the 1904 date system, Excel stores January 1, 1904, as serial number 0 (January 2, 1904, is serial number 1). For example, in the 1900 date system, Excel stores January 1, 1998, as serial number 35796 because it is 35,795 days after January 1, 1900.

Microsoft Excel for Windows and Microsoft Excel for the Macintosh use different default date systems. Excel for Windows uses the 1900 date system, in which serial numbers correspond to the dates January 1, 1900, through December 31, 9999. Excel for the Macintosh uses the 1904 date system, in which serial numbers correspond to the dates January 1, 1904, through December 31, 9999.

Numbers to the right of the decimal point in the serial number represent the time; numbers to the left represent the date. For example, in the 1900 date system, the serial number 367.5 represents the date-time combination 12:00 P.M., January 1, 1901. You can change the date system by selecting or clearing the 1904 date system check box on the Calculation tab of the Options command (Tools menu).

The date system is changed automatically when you open a document from another platform. For example, if you are working in Excel for Windows and you open a document created in Excel for the Macintosh, the 1904 date system check box is selected automatically.

The NOW function changes only when the worksheet is calculated or when a macro that contains the function is run. It is not updated continuously.

Examples

If you are using the 1900 date system and your computer's built-in clock is set to 12:30:00 P.M., 1-Jan-1987, then: NOW() equals 31778.52083 Ten minutes later:

NOW() equals 31778.52778

Suppose that you want to create a summary of that shows, for each salesperson, the total number of orders placed and the total amount invoiced for a given period. To count the number of orders placed, use the COUNTIF worksheet function. To calculate the total amount invoiced, use the SUMIF worksheet function.

The COUNTIF worksheet function counts the number of orders placed for each salesperson.

Suppose that you want to create a summary of that shows, for each salesperson, the total number of orders placed and the total amount invoiced for a given period. To count the number of orders placed, use the COUNTIF worksheet function. To calculate the total amount invoiced, use the SUMIF worksheet function.

The COUNTIF worksheet function counts the number of orders placed for each salesperson.

COUNTIF has two arguments: the range to be checked and the value to check for within the range (the criteria).

=COUNTIF(range,criteria)

For Buchanan, the function (in cell B32) looks like this:

=COUNTIF(A2:A26,A32)

The function counts the number of times the name in cell A32 (the criteria argument) appears in the Salesperson list (A2:A26, the range argument).

The SUMIF worksheet function calculates the total amount invoiced for each salesperson.

The SUMIF worksheet function checks for a value within a range and then sums all the corresponding values in another range. SUMIF has three arguments: the range to be checked, the value to check for within the range (the criteria), and the range containing the values to be summed.

=SUMIF(range,criteria,sum_range)

For Buchanan, the function (in cell C32) looks like this:

=SUMIF(A2:A26,A32,B2:B26)

The formula checks for the text in cell A32 (the criteria argument) in the Salesperson list (A2:A26, the range argument) and then sums the corresponding amounts from the Total Invoice column (B2:B26 the sum_range argument).

Suppose that your company determines sales bonuses on a sliding scale, awarding either 10 percent or 15 percent, based on the invoice amount. To determine which one of two values to use, based on a condition that is either true or false, use the IF worksheet function.

The IF worksheet function returns a bonus of either 10% or 15%, based on the invoice amount.

The IF worksheet function checks a condition that must be either true or false. If the condition is true, the function returns one value; if the condition is false, the function returns another value. The function has three arguments: the condition you want to check, the value to return if the condition is true, and the value to return if the condition is false.

=IF(logical_test,value_if_true,value_if_false)

For Suyama's \$8,000 invoice, the function (in cell C4) looks like this:

=IF(B4<10000,10%,15%)

If the invoice amount is less than \$10,000 (the logical_test argument), the bonus is 10 percent (the value_if_true argument). If the invoice amount is \$10,000 or greater, the bonus is 15 percent (the value _if_false argument).

Suppose you have multiple conditions you want to check. The Conditional Sum Wizard can create the conditional formulas for you.

The Conditional Sum Wizard quickly builds formulas that contain multiple conditions. You can use the mouse to define the conditions and then the wizard adds the formulas to your worksheet.

In the wizard, you specify the location of the list, the condition to check, and the location for the result. In the preceding example, you are summing the invoice amounts for Buchanan's sales that were greater than \$10,000.

The wizard then creates an array formula that calculates the result for you. If you need to change the condition, you can use the wizard again and replace the results in the location you originally specified.

The Conditional Sum Wizard is an add-in program supplied with Excel.

COUNTIF has two arguments: the range to be checked and the value to check for within the range (the criteria).

=COUNTIF(range,criteria)

For Buchanan, the function (in cell B32) looks like this:

=COUNTIF(A2:A26,A32)

The function counts the number of times the name in cell A32 (the criteria argument) appears in the Salesperson list (A2:A26, the range argument).

The SUMIF worksheet function calculates the total amount invoiced for each salesperson.

The SUMIF worksheet function checks for a value within a range and then sums all the corresponding values in another range. SUMIF has three arguments: the range to be checked, the value to check for within the range (the criteria), and the range containing the values to be summed.

=SUMIF(range,criteria,sum_range)

For Buchanan, the function (in cell C32) looks like this:

=SUMIF(A2:A26,A32,B2:B26)

The formula checks for the text in cell A32 (the criteria argument) in the Salesperson list (A2:A26, the range argument) and then sums the corresponding amounts from the Total Invoice column (B2:B26 the sum_range argument).

Suppose that your company determines sales bonuses on a sliding scale, awarding either 10 percent or 15 percent, based on the invoice amount. To determine which one of two values to use, based on a condition that is either true or false, use the IF worksheet function.

The IF worksheet function returns a bonus of either 10% or 15%, based on the invoice amount.

The IF worksheet function checks a condition that must be either true or false. If the condition is true, the function returns one value; if the condition is false, the function returns another value. The function has three arguments: the condition you want to check, the value to return if the condition is true, and the value to return if the condition is false.

=IF(logical_test,value_if_true,value_if_false)

For Suyama's \$8,000 invoice, the function (in cell C4) looks like this:

=IF(B4<10000,10%,15%)

If the invoice amount is less than \$10,000 (the logical_test argument), the bonus is 10 percent (the value_if_true argument). If the invoice amount is \$10,000 or greater, the bonus is 15 percent (the value _if_false argument).

Suppose you have multiple conditions you want to check. The Conditional Sum Wizard can create the conditional formulas for you.

The Conditional Sum Wizard quickly builds formulas that contain multiple conditions. You can use the mouse to define the conditions and then the wizard adds the formulas to your worksheet.

In the wizard, you specify the location of the list, the condition to check, and the location for the result. In the preceding example, you are summing the invoice amounts for Buchanan's sales that were greater than \$10,000.

The wizard then creates an array formula that calculates the result for you. If you need to change the condition, you can use the wizard again and replace the results in the location you originally specified.

The Conditional Sum Wizard is an add-in program supplied with Excel.

In certain cases, you may need to use a function as one of the arguments of another function. For example, the formula in Figure 1 uses a nested AVERAGE function and compares the result with the value 50.

Valid returns   When a nested function is used as an argument, it must return the same type of value that the argument uses. For example, if the argument returns a TRUE or FALSE value, then the nested function must return a TRUE or FALSE. If it doesn't, Microsoft Excel displays a #VALUE! Error value.

Nesting level limits   A formula can contain up to seven levels of nested functions. When Function B is used as an argument in Function A, Function B is a second-level function. For instance, the AVERAGE function and the SUM function in Figure 1 are both second-level functions because they are arguments of the IF function. A function nested within the AVERAGE function would be a third-level function, and so on. To nest functions   You can use the Formula Palette to nest functions as arguments. For example, in Figure 2, you could nest the SUM function in the IF function by clicking in the Value_if_true edit box, clicking the down arrow in the formula bar Functions box, and then clicking SUM.

To switch between functions in the Formula Palette, click the name of the function in the formula bar. For example, to change the range for the AVERAGE function in Figure 2, click AVERAGE in the formula bar. Learn about using the Formula Palette to enter and edit formulas.

Searches for a value in the leftmost column of a table, and then returns a value in the same row from a column you specify in the table. Use VLOOKUP instead of HLOOKUP when your comparison values are located in a column to the left of the data you want to find.

Syntax

VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)

Lookup_value   is the value to be found in the first column of the array. Lookup_value can be a value, a reference, or a text string.

Table_array   is the table of information in which data is looked up. Use a reference to a range or a range name, such as Database or List.

•   If range_lookup is TRUE, the values in the first column of table_array must be placed in ascending order: , -2, -1, 0, 1, 2, , A-Z, FALSE, TRUE; otherwise VLOOKUP may not give the correct value. If range_lookup is FALSE, table_array does not need to be sorted.

•   You can put the values in ascending order by choosing the Sort command from the Data menu and selecting Ascending.

•   The values in the first column of table_array can be text, numbers, or logical values.

•   Uppercase and lowercase text are equivalent.

Col_index_num   is the column number in table_array from which the matching value must be returned. A col_index_num of 1 returns the value in the first column in table_array; a col_index_num of 2 returns the value in the second column in table_array, and so on. If col_index_num is less than 1, VLOOKUP returns the #VALUE! error value; if col_index_num is greater than the number of columns in table_array, VLOOKUP returns the #REF! error value.

Range_lookup   is a logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match. If TRUE or omitted, an approximate match is returned. In other words, if an exact match is not found, the next largest value that is less than lookup_value is returned. If FALSE, VLOOKUP will find an exact match. If one is not found, the error value #N/A is returned.

Remarks

•   If VLOOKUP can't find lookup_value, and range_lookup is TRUE, it uses the largest value that is less than or equal to lookup_value.

•   If lookup_value is smaller than the smallest value in the first column of table_array, VLOOKUP returns the #N/A error value.

•   If VLOOKUP can't find lookup_value, and range_lookup is FALSE, VLOOKUP returns the #N/A value.

Examples

On the preceding worksheet, where the range A4:C12 is named Range:

VLOOKUP(1,Range,1,TRUE) equals 0.946 VLOOKUP(1,Range,2) equals 2.17

VLOOKUP(1,Range,3,TRUE) equals 100

VLOOKUP(.746,Range,3,FALSE) equals 200

VLOOKUP(0.1,Range,2,TRUE) equals #N/A, because 0.1 is less than the smallest value in column A

VLOOKUP(2,Range,2,TRUE) equals 1.71

Microsoft Excel includes 12 worksheet functions that analyze data stored in lists or databases. Each of these functions, referred to collectively as the Dfunctions, uses three arguments: database, field, and criteria. These arguments refer to the worksheet ranges that are used by the function.

Syntax

Dfunction(database,field,criteria)

Database   is the range of cells that make up the list or database.

•   In Microsoft Excel, a database is a list of related data in which rows of related information are records and columns of data are fields. The first row of the list contains labels for each column. The reference can be entered as a cell range or as a name that represents the range that contains the list. For guidelines for creating lists on worksheets, click .

•   In all database functions, if the database reference is to a cell inside a PivotTable, the calculation is done on only the PivotTable data.

•   If you want to calculate subtotal values in your list, use the Subtotals command on the Data menu to insert subtotal values. Field   indicates which column is used in the function. Columns of data in the list must have an identifying label in the first row. Field can be given as text with the column label enclosed between double quotation marks, such as "Age" or "Yield" in the example list below, or as a number that represents the position of the column in the list: 1 for the first column (Tree in the example below), 2 for the second (Height), and so on.

Criteria is a reference to a range of cells that specify conditions for the function. The function returns information from the list that matches the conditions specified in the criteria range. The criteria range includes a copy of the column label in the list for the column you want the function to summarize. The criteria reference can be entered as a cell range, such as A1:F2 in the example database below, or as a name that represents the range, such as "Criteria." For more examples of conditions you can specify as criteria, click .

Tips

•   You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label for specifying the condition.

For example, if the range G1:G2 contains the column label Income in G1 and the amount 10,000 in G2, you could define the range as MatchIncome and use that name as the criteria argument in the database functions.

•   Although the criteria range can be located anywhere on the worksheet, do not place the criteria range below the list. If you add more information to the list by using the Form command on the Data menu, the new information is added to the first row below the list. If the row below the list is not blank, Microsoft Excel cannot add the new information.

•   Make sure the criteria range does not overlap the list.

•   To perform an operation on an entire column in a database, enter a blank line below the column labels in the criteria range.

Examples

The following illustration shows a database for a small orchard. Each record contains information about one tree. The range A5:E11 is named Database, and the range A1:F3 is named Criteria.

following illustration shows a database for a small orchard. Each record contains information about one tree. The range A5:E11 is named Database, and the range A1:F3 is named Criteria.

following illustration shows a database for a small orchard. Each record contains information about one tree. The range A5:E11 is named Database, and the range A1:F3 is named Criteria.

DCOUNT(Database,"Age",A1:F2) equals 1. This function looks at the records of apple trees between a height of 10 and 16 and counts how many of the Age fields in those records contain numbers.

DCOUNTA(Database,"Profit",A1:F2) equals 1. This function looks at the records of apple trees between a height of 10 and 16 and counts how many of the Profit fields in those records are not blank.

DMAX(Database,"Profit",A1:A3) equals \$105.00, the maximum profit of apple and pear trees.

DMIN(Database,"Profit",A1:B2) equals \$75.00, the minimum profit of apple trees over 10.

DSUM(Database,"Profit",A1:A2) equals \$225.00, the total profit from apple trees.

DSUM(Database,"Profit",A1:F2) equals \$75.00, the total profit from apple trees with a height between 10 and 16.

DPRODUCT(Database,"Yield",A1:F2) equals 140, the product of the yields from apple trees with a height between 10 and 16.

DAVERAGE(Database,"Yield",A1:B2) equals 12, the average yield of apple trees over 10 feet in height.

DAVERAGE(Database,3,Database) equals 13, the average age of all trees in the database.

DSTDEV(Database,"Yield",A1:A3) equals 2.97, the estimated standard deviation in the yield of apple and pear trees if the data in the database is only a sample of the total orchard population.

DSTDEVP(Database,"Yield",A1:A3) equals 2.65, the true standard deviation in the yield of apple and pear trees if the data in the database is the entire population.

DVAR(Database,"Yield",A1:A3) equals 8.8, the estimated variance in the yield of apple and pear trees if the data in the database is only a sample of the total orchard population.

DVARP(Database,"Yield",A1:A3) equals 7.04, the true variance in the yield of apple and pear trees if the data in the database is the entire orchard population.

DGET(Database,"Yield",Criteria) returns the #NUM! error value because more than one record meets the criteria.

Calculates the payment for a loan based on constant payments and a constant interest rate.

Syntax

PMT(rate,nper,pv,fv,type)

For a more complete description of the arguments in PMT, see PV.

Rate   is the interest rate for the loan.

Nper   is the total number of payments for the loan.

Pv   is the present value, or the total amount that a series of future payments is worth now; also known as the principal.

Fv   is the future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be 0 (zero), that is, the future value of a loan is 0.

Type   is the number 0 (zero) or 1 and indicates when payments are due.

 Set type equal to If payments are due 0 or omitted At the end of the period 1 At the beginning of the period

Remarks

•   The payment returned by PMT includes principal and interest but no taxes, reserve payments, or fees sometimes associated with loans.

•   Make sure that you are consistent about the units you use for specifying rate and nper. If you make monthly payments on a four-year loan at an annual interest rate of 12 percent, use 12%/12 for rate and 4*12 for nper. If you make annual payments on the same loan, use 12 percent for rate and 4 for nper.

Tip   To find the total amount paid over the duration of the loan, multiply the returned PMT value by nper.

Examples

The following formula returns the monthly payment on a \$10,000 loan at an annual rate of 8 percent that you must pay off in 10 months:

PMT(8%/12, 10, 10000) equals -\$1,037.03

For the same loan, if payments are due at the beginning of the period, the payment is:

PMT(8%/12, 10, 10000, 0, 1) equals -\$1,030.16

The following formula returns the amount someone must pay to you each month if you loan that person \$5,000 at 12 percent and want to be paid back in five months:

PMT(12%/12, 5, -5000) equals \$1,030.20

You can use PMT to determine payments to annuities other than loans. For example, if you want to save \$50,000 in 18 years by saving a constant amount each month, you can use PMT to determine how much you must save. If you assume you'll be able to earn 6 percent interest on your savings, you can use PMT to determine how much to save each month.

PMT(6%/12, 18*12, 0, 50000) equals -\$129.08

If you pay \$129.08 into a 6 percent savings account every month for 18 years, you will have \$50,000.

Joins several text strings into one text string.

Syntax

CONCATENATE (text1,text2, )

Text1, text2,    are 1 to 30 text items to be joined into a single text item. The text items can be text strings, numbers, or single-cell references.

Remarks

The "&" operator can be used instead of CONCATENATE to join text items.

Examples

CONCATENATE("Total ", "Value") equals "Total Value". This is equivalent to typing

"Total"&" "&"Value"

Suppose in a stream survey worksheet, C2 contains "species", C5 contains " brook trout", and C8 contains the total 32.

CONCATENATE("Stream population for ",C5," ",C2," is ",C8,"/mile")

equals "Stream population for brook trout species is 32/mile"

# Why charts?

Charts are visually appealing and make it easy for users to see comparisons, patterns, and trends in data. For instance, rather than having to analyze several columns of worksheet numbers, you can see at a glance whether sales are falling or rising over quarterly periods, or how the actual sales compare to the projected sales.

You can create a chart on its own sheet or as an embedded object on a worksheet. You can also publish a chart on a Web page. To create a chart, you must first enter the data for the chart on the worksheet. Then select that data and use the Chart Wizard to step through the process of choosing the chart type and the various chart options.

## Worksheet data and chart

You can also create a chart in one step without using the Chart Wizard. When created this way, the chart uses a default chart type and formatting that you can change later.

A chart is linked to the worksheet data it's created from and is updated automatically when you change the worksheet data.

How worksheet data appears in a chart

Axis values   Microsoft Excel creates the axis values from the worksheet data. Note that the axis values in the example above range from 0 to 140000, which encompasses the range of values on the worksheet. Unless you specify differently, Excel uses the format of the upper-left cell in the value range as the number format for the axis. Category names Excel uses column or row headings in the worksheet data for category axis names. In the example above, the worksheet row headings 1st Quarter, 2nd Quarter, and so on appear as category axis names. You can change whether Excel uses column or row headings for category axis names or create different names.

Chart data series names   Excel also uses column or row headings in the worksheet data for series names. Series names appear in the chart legend. In the example above, the row headings Projected and Actual appear as series names. You can change whether Excel uses column or row headings for series names or create different names.

Data markers   Data markers with the same pattern represent one data series. Each data marker represents one number from the worksheet. In the example above, the rightmost data marker represents the Actual 4th Quarter value of 120000.

Tips   A chart tip that tells you the name of a chart item appears when you rest the pointer over the chart item. For example, when you rest the pointer over the legend, the chart tip Legend appears.

You can create a chart on its own chart sheet or as an embedded chart on a worksheet. Either way, the chart is linked to the source data on the worksheet, which means the chart is updated when you update the worksheet data.

Embedded charts   An embedded chart is considered a graphic object and is saved as part of the worksheet on which it is created. Use embedded charts when you want to display or print one or more charts with your worksheet data.

Chart sheets   A chart sheet is a separate sheet within your workbook that has its own sheet name. Use a chart sheet when you want to view or edit large or complex charts separately from the worksheet data or when you want to preserve screen space as you work on the worksheet.

You can create either an embedded chart or a chart sheet.

Select the cells that contain the data that you want to appear in the chart.

1.  If you want the column and row labels to appear in the chart, include the cells that contain them in the selection.

2.  Click Chart Wizard

Follow the instructions in the Chart Wizard.

Select the first group of cells that contain the data you want to include.

While holding down CTRL, select any additional cell groups you want to include.

The nonadjacent selections must form a rectangle.

Click Chart Wizard

Follow the instructions in the Chart Wizard.

## Change the cell range used to create a chart

Click the chart you want to change.

On the Chart menu, click Source Data, and then click the Data Range tab.

Make sure the entire reference in the Data range box is selected.

On the worksheet, select the cells that contain the data you want to appear in the chart.  If you want the column and row labels to appear in the chart, include the cells that contain them in the selection.

The values in a chart are linked to the worksheet from which the chart is created. The chart is updated when you change the data on the worksheet.

Open the worksheet that contains the data plotted in the chart.

In the cell that contains the value you want to change, type a new value. Press ENTER.

Click the chart to which you want to add a text box.

On the Drawing toolbar, click Text Box

Click where you want one corner of the text box, and then drag until the box is the size you want.

Type the text you want in the box. The text will wrap inside the box.

To start a new line inside the box, press ENTER.

When you finish typing, press ESC or click outside of the text box.

## Change an embedded chart to a chart sheet, and vice versa

Click the chart that you want to move or change.

On the Chart menu, click Location.

To place the chart on a new chart sheet, click As new sheet, and then type a name for the new chart sheet in the As new sheet box.

To place the chart as an embedded object on a worksheet, click As object in, click a sheet name in the As object in box, and then click OK. Drag the embedded chart where you want it on the worksheet.

The chart type associated with the selected data series or data point determines the type of data label you can add.

To add data labels to a data series, click the data series.

To add a data label to a single data point, click the data series that contains the data marker you want to label, and then click the data marker for the data point you want to label.

On the Format menu, click Selected Data Series or Data Point.

On the Data Labels tab, select the options you want.

Tip   You can quickly label all data points. Click the chart, click Chart Options on the Chart menu, and then select the options you want on the Data Labels tab.

1.  Click the chart to which you want to add a title.

2.  On the Chart menu, click Chart Options, and then click the Titles tab.

3.  To add a chart title, click in the Chart title box, and then type the text you want.

4.  To add one or more axis titles, click in the appropriate box for each title, and then type the text you want.

1.  Click the chart to which you want to add a legend.

2.  On the Chart menu, click Chart Options, and then click the Legend tab.

3.  Select the Show legend check box.

4.  Under Placement, click the option you want.

Data tables can be displayed in line, area, column, and bar charts. In bar charts, the data table does not replace an axis of the chart but is aligned to the chart. Click the chart to which you want to add a data table.

On the Chart menu, click Chart Options, and then click the Data Table tab. To display the chart data in a grid at the bottom of the chart, select the Show data table check box.

To hide the data table, clear the check box.

For most 2-D charts, you can change the chart type of either a data series or the entire chart. For bubble charts, you can change only the type of the entire chart. For most 3D charts, changing the chart type affects the entire chart. For 3-D bar and column charts, you can change a data series to the cone, cylinder, or pyramid chart type.

Do one of the following:

1.   To change the chart type of the entire chart, click the chart.

2.   To change the chart type of a data series, click the data series.  On the Chart menu, click Chart Type.

On the Standard Types or Custom Types tab, click the chart type you want.

To apply the cone, cylinder, or pyramid chart type to a 3-D bar or column data series, click Cylinder, Cone, or Pyramid in the Chart type box on the Standard Types tab, and then select the Apply to selection check box.

## Change colors, patterns, lines, fills, and borders in charts

Use this procedure to change colors, apply a texture or pattern, or change the line width or border style for data markers the chart area the plot area ,gridlines, axes and tick marks in 2-D and 3-D charts, Trendlines and error bars in 2-D charts, and the walls and floor in 3-D charts.

Double-click the chart item you want to change.

If necessary, click the Patterns tab, and then select the options you want.

To specify a fill effect, click Fill Effects, and then select the options you want on the Gradient, Texture, or Pattern tabs. For information about adding a picture to a chart item, click

Select the first group of cells that contain the data you want to include.

While holding down CTRL, select any additional cell groups you want to include.

The nonadjacent selections must form a rectangle.

Click Chart Wizard

Follow the instructions in the Chart Wizard.

In Microsoft Excel, you can easily use a list as a database. When you perform database tasks, such as finding, sorting, or subtotaling data, Microsoft Excel automatically recognizes the list as a database and uses the following list elements to organize the data.

The columns in the list are the fields in the database.

The column labels in the list are the field names in the database. Each row in the list is a record in the database.

Microsoft Excel has a number of features that make it easy to manage and analyze data in a list. To take advantage of these features, enter data in a list according to the following guidelines.

Use only one list per worksheet   Avoid having more than one list on a worksheet. Some list management features, such as filtering, can be used on only one list at a time.

Put similar items in one column   Design the list so that all rows have similar items in the same column.

Keep the list separate   Leave at least one blank column and one blank row between the list and other data on the worksheet. Excel can then more easily detect and select the list when you sort, filter, or insert automatic subtotals.

Position critical data above or below the list Avoid placing critical data to the left or right of the list; the data might be hidden when you filter the list.

Show rows and columns   Make sure any hidden rows or columns are displayed before making changes to the list. When rows and columns in a list are not showing, data can be deleted inadvertently.

Use formatted column labels   Create column labels in the first row of the list. Excel uses the labels to create reports and to find and organize data. Use a font, alignment, format, pattern, border, or capitalization style for column labels that is different from the format you assign to the data in the list. Format the cells as text before you type the column labels.

Use cell borders   When you want to separate labels from data, use cell borders — not blank rows or dashed lines — to insert lines below the labels.

Avoid blank rows and columns   Avoid putting blank rows and columns in the list so that Excel can more easily detect and select the list.

Don't type leading or trailing spaces   Extra spaces at the beginning or end of a cell affect sorting and searching. Instead of typing spaces, indent the text within the cell.

Extend list formats and formulas   When you add new rows of data to the end of a list, Excel uses consistent formatting and formulas. Three of the five preceding cells must use the same format or formula for this to occur.

When you turn on extended formats and formulas, Microsoft Excel automatically formats new data that you type at the end of a list to match the preceding rows and automatically copies formulas that repeat in every row. To be extended, formats and formulas must appear in at least three of the five list rows preceding the new row. On the Tools menu, click Options, and then click the Edit tab.

Do one of the following:

To automatically format new items that you add to the end of a list to match the format of the rest of the list, select the Extend list formats and formulas check box.  To prevent automatic formatting, clear the check box.

When you sort a list, Microsoft Excel rearranges rows according to the contents of a column you choose — the Sort By column.

Ascending sort   To arrange a list alphanumerically using the data in one column, you can specify an ascending sort order (0 to 9, leading spaces, punctuation, A to Z). In the following example, sorting the list in ascending order by the "Sold by" column puts the names of the salespersons in alphabetical order.

You can choose a sort based on the contents of two or more columns. In the following example, the list is first sorted by region. Then the rows for each region are sorted by salesperson so that the names of the salespersons are alphabetized within each region.

Microsoft Excel sorts lists in ascending, alphanumeric order by default. If you need to sort months and weekdays according to their calendar order instead of their alphabetical order, use a custom sort order.

In the following example, the list is sorted with the months in calendar order.

You can also rearrange lists in a specific order by creating your own custom sort orders. For example, if you have a list that contains the entry "Low," "Medium," or "High" in a column, you can create a sort order that arranges rows with "Low" first, rows with "Medium" next, and rows with "High" last.

If you previously sorted a list on the same worksheet, Microsoft Excel uses the same sorting options unless you change them.

Click a cell in the column you would like to sort by. Click Sort Ascending or Click Sort Descending.

For best results, the list you sort should have column labels.

1.  Click a cell in the list you want to sort.

2.  On the Data menu, click Sort.

3.  In the Sort by and Then by boxes, click the columns you want to sort.

If you need to sort by more than three columns, sort by the least important columns first. For example, if your list contains employee information and you need to organize it by Department, Title, Last Name, and First Name, sort the list twice. First, click First Name in the Sort by box and sort the list. Second, click Department in the Sort by box, click Title in the first then by box, and click Last Name in the second then by box, and sort the list.

Select any other sort options you want, and then click OK.

Repeat steps 2 through 4 if needed, using the next most important columns.

If the column you specify in the Sort by box has duplicate items, you can sort the values further by specifying another column in the first Then by box. If there are duplicate items in the second column, you can specify a third column to sort by in the second then by box.

When you sort rows that are part of a worksheet outline, Microsoft Excel sorts the highest-level groups (level 1) so that the detail rows or columns stay together, even if the detail rows or columns are hidden

## Sort columns based on the contents of rows

1.  Click a cell in the list you want to sort.

2.  On the Data menu, click Sort.

3.  Click Options.

4.  Under Orientation, click Sort left to right, and then click OK.

5.  In the Sort by and Then by boxes, click the rows you want to sort.

1.  Select a cell or range in the list you want to sort.

2.  On the Data menu, click Sort.

3.  Click Options.

4.  Under First key sort order, click the custom sort order you want, and then click OK.

5.  Click any other sorting options you want.

The custom sort order applies only to the column specified in the Sort by box. To sort multiple columns by using a custom sort order, sort by each column separately. For example, to sort by columns A and B, in that order, first sort by column B, and then specify the custom sort order by using the Sort Options dialog box. Next, sort the list by column A.

If you want to arrange a list in a specific order — for example, organizational data — you can sort it by using a custom list for the custom sort order.

Microsoft Excel uses specific sort orders to arrange data according to the value, not the format, of the data.

In an ascending sort, Excel uses the following order. (In a descending sort, this sort order is reversed except for blank cells, which are always placed last.)

Numbers   Numbers are sorted from the smallest negative number to the largest positive number.

Alphanumeric sort   When you sort alphanumeric text, Excel sorts left to right, character by character. For example, if a cell contains the text "A100," Excel places the cell after a cell that contains the entry "A1" and before a cell that contains the entry "A11."Text and text that includes numbers are sorted in the following order: 0 1 2 3 4 5 6 7 8 9 (space) ! " # \$ % & ( ) * , . / : ; ? @ [ \ ] ^ _ ` { | } ~ + < = > A B C

D E F G H I J K L M N O P Q R S T U V W X Y Z

Apostrophes (') and hyphens (-) are ignored, with one exception: If two text strings are the same except for a hyphen, the text with the hyphen is sorted last.

Logical values   In logical values, FALSE is placed before TRUE.

Error values   All error values are equal.

Blanks   Blanks are always placed last.

You can apply filters to only one list on a worksheet at a time.

1.  Click a cell in the list you want to filter.

2.  On the Data: Filter: AutoFilter.

To display only the rows that contain a specific value, click the arrow in the column that contains the data you want to display.

Click the value.

To apply an additional condition based on a value in another column, repeat steps 3 and 4 in the other column.

To filter the list by two values in the same column, or to apply comparison operators other than Equals, click the arrow in the column, and then click Custom. For information about displaying rows by comparing values, click.

When you apply a filter to a column, the only filters available for other columns are the values visible in the filtered list.

You can apply up to two conditions to a column by using AutoFilter. To apply more complex filters or to copy filtered rows to another location, you can use advanced filters.

To find specific values in rows in a list by using one or two comparison criteria for the same column, point to Filter on the Data menu, click AutoFilter, click the arrow in the column that contains the data you want to compare, and then click Custom.  To match one criterion, click the comparison operator you want to use in the first box under Show rows where, and then enter the value you want to match in the box immediately to the right of the comparison operator.

To display rows that meet two conditions, enter the comparison operator and value you want, and then click the And button. In the second comparison operator and value boxes, enter the operator and value you want.

To display rows that meet either one condition or another condition, enter the comparison operator and value you want, and then click the Or button. In the second comparison operator and value boxes, enter the operator and value you want.

To remove a filter from one column in a list, click the arrow next to the column, and then click all.

To remove filters applied to all columns in the list, on the Data menu point to Filter, and then click Show All.

To remove the filter arrows from a list, on the Data menu point to Filter, and then click AutoFilter.

## Automatic filter options

 To Click Display all rows All Display all rows that fall within the upper or lower limits you specify, either by item or percentage; for example, the amounts within the top 10 percent of sales Top 10 Apply two criteria values within the current column, or use comparison operators other than AND (the default operator) Custom Display only rows that contain a blank cell in the column Blanks Display only rows that contain a value in the column NonBlanks

The Blanks and NonBlanks options are available only if the column you want to filter contains a blank cell.

Your worksheet should have at least three blank rows above the list that can be used as a criteria range. The list must have column labels.

1.  Select the column labels from the list for the columns that contain the values you want to filter, and click Copy

2.  Select the first blank row of the criteria range, and click Paste .

3.  In the rows below the criteria labels, type the criteria you want to match. Make sure there is at least one blank row between the criteria values and the list.

4.  Click a cell in the list.

5.  On the Data menu, point to Filter, and then click Advanced Filter.

6.  To filter the list by hiding rows that don't match your criteria, click Filter the list, in-place.

7.  To filter the list by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.

In the Criteria range box, enter the reference for the criteria range, including the criteria labels. To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog

You can name a range Criteria, and the reference for the range will appear automatically in the Criteria range box. You can also define the name Database for the range of data to be filtered and define the name Extract for the area where you want to paste the rows, and these ranges will appear automatically in the List range and Copy to boxes, respectively.

When you copy filtered rows to another location, you can specify which columns to include in the copy. Before filtering, copy the column labels for the columns you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.

Advanced filter criteria can include multiple conditions applied in a single column, multiple criteria applied to multiple columns, and conditions created as the result of a formula.

Multiple conditions in a single column   If you have two or more conditions for a single column, type the criteria directly below each other in separate rows. For example, the following criteria range displays the rows that contain either "Davolio," "Buchanan," or "Suyama" in the Salesperson column.

One condition in two or more columns   To find data that meets one condition in two or more columns, enter all the criteria in the same row of the criteria range. For example, the following criteria range displays all rows that contain "Produce" in the Type column, "Davolio" in the Salesperson column, and sales values greater than \$1,000.

Note   You can also specify multiple conditions for different columns and display only the rows that meet all the conditions by using the AutoFilter command on the Data menu.

One condition in one column or another   To find data that meets either a condition in one column or a condition in another column, enter the criteria in different rows of the criteria range. For example, the following criteria range displays all rows that contain either "Produce" in the Type column, "Davolio" in the Salesperson column, or sales values greater than \$1,000.

One of two sets of conditions for two columns To find rows that meet one of two sets of conditions, where each set includes conditions for more than one column, type the criteria in separate rows. For example, the following criteria range displays the rows that contain both "Davolio" in the Salesperson column and sales values greater than \$3,000, and also displays the rows for salesperson Buchanan with sales values greater than \$1,500.

Conditions created as the result of a formula You can use a calculated value that is the result of a formula as your criterion. When you use a formula to create a criterion, do not use a column label for a criteria label; either keep the criteria label blank or use a label that is not a column label in the list. For example, the following criteria range displays rows that have a value in column G greater than the average of cells E5: E14; it does not use a criteria label.

Notes

The formula you use for a condition must use a relative reference to refer to the column label (for example, Sales) or the corresponding field in the first record. All other references in the formula must be absolute references, and the formula must evaluate to TRUE or FALSE. In the formula example, "G5" refers to the field (column G) for the first record (row 5) of the list.

You can use a column label in the formula instead of a relative cell reference or a range name. When Microsoft Excel displays an error value such as #NAME? or #VALUE! in the cell that contains the criterion, you can ignore this error because it does not affect how the list is filtered.

You can use the following types of comparison criteria in a criteria range, with either an advanced filter or a custom filter.

To find rows in a list that contain an exact value, type the text, number, date, or logical value in the cell below the criteria label. For example, if you type 98133 below a Postal Code label in the criteria range, Microsoft Excel displays only rows that contain the postal code value "98133."

When you use text as criteria with an advanced filter, Microsoft Excel finds all items that begin with that text. For example, if you type the text Dav as a criterion, Microsoft Excel finds "Davolio," "David," and "Davis." To match only the specified text, type the following formula, where text is the text you want to find. =''=text''

To find text values that share some characters but not others, use a wildcard character. A wildcard character represents one or more unspecified characters.

 Use
 To find
 ? (question mark)
 Any single character in the same position as the question           mark For example, sm?th finds "smith" and "smyth"
 * (asterisk)
 Any number of characters in the same position as the asterisk For example, *east finds "Northeast" and "Southeast"
 ~ (tilde) followed by ?, *, or ~
 A       question     mark,      asterisk, For example, fy91~? finds "fy91?" or tilde

To display only rows that fall within certain limits, type a comparison operator, followed by a value, in the cell below the criteria label. For example, to find rows whose unit values are greater than or equal to 1,000, type >=1000 under the Units criteria label in the criteria range.

When evaluating data, Microsoft Excel does not distinguish between uppercase and lowercase characters.

Wild card characters and comparison operators that rely on character positions — beginning, ending, or containing — work only with text values, not with numeric data, in Microsoft Excel.

Lookup Wizard   You can find a value in a worksheet list that has row and column labels. The Lookup Wizard helps you find other values in a row when you know the value in one column, and vice versa.

For example, if you have an inventory list of product numbers, descriptions, and prices, you can quickly find the description or the price of a product when you type in the appropriate product number. The Lookup Wizard creates the formula you need.

Formulas   If you prefer to write your own formulas to look up values in lists, you can use any of the following worksheet functions:

LOOKUP finds a value in one row or column of values that are sorted in ascending order. It then returns the value from the same position in a different row or column. You can use LOOKUP to find values in lists that don't have row or column labels. VLOOKUP finds a value in a list with row labels. Use VLOOKUP when your list has row labels in the leftmost column and you want to look up a value in another column based on the row label. By default, you must sort the list before you can use VLOOKUP.

HLOOKUP also finds a value in a list with column labels. Use HLOOKUP when your list has column labels in the topmost row and you want to look up a value in another row based on the column label. By default, you must sort the list before you can use HLOOKUP.

You can use the INDEX and MATCH functions together to find a value in a list based on a row or column label, or both labels. INDEX returns a reference to a cell at the intersection of a particular row and column within a range, and MATCH finds the relative position of a cell within a range, based on a value you want to look up. In combination, these functions return a value based on either a row or column label. The Lookup Wizard uses INDEX and MATCH in the formulas it creates.

The Lookup Wizard is an add-in program; if the Lookup command is not on the

1.  Click a cell in the list.

2.  On the Tools menu, point to Wizard, and then click Lookup.

3.  Follow the instructions in the wizard.

Microsoft Excel provides several ways to summarize values on your worksheet. You can create formulas that summarize data in columns, use tools that generate reports that summarize data in lists, and create PivotTable and PivotChart reports that summarize the data and allow you to interactively change the view of the data.

Show a total for a range   When you want to select a range of cells and quickly see a total of their values (without entering the sum on your worksheet), look at the status bar. There, the Auto Calculate feature displays the sum of a selected range. If the selected range contains hidden cells or cells that are hidden by filtering, the hidden values are not included in the sum.

If you want to summarize values in a list based on specific conditions, you can use the Conditional Sum Wizard. For example, if your list contains sales amounts for different salespeople, the Conditional Sum Wizard can help you create a formula that calculates the total sales amount for one salesperson.

The Conditional Sum Wizard is an add-in program. If the Conditional Sum command is not on the Wizard submenu on the Tools menu, you need to install and load the add-in program.

1.  Click a cell in the list.

2.  On the Tools menu, point to Wizard, and then click Conditional Sum.

3.  Follow the instructions in the wizard.

4.  The formulas created by the Conditional Sum Wizard are array formulas. After you edit these formulas, you must press CTRL+SHIFT+ENTER to lock in the formulas.

Subtotals   Microsoft Excel calculates subtotal values by using a summary function, such as Sum or Average. You can display subtotals by using more than one type of calculation in a list at a time.

Grand totals   Grand total values are derived from detail data, not from the values in the subtotal rows. For example, if you use the summary function Average, the grand total row displays an average of all detail data in the list, not an average of the values in the subtotal rows.

Automatic recalculation   Excel recalculates subtotals and grand total values automatically as you edit detail data.

Sort the list by the column for which you want to calculate subtotals. For example, to summarize the units sold by each salesperson in a list of salespeople, sales amounts, and the number of units sold, sort the list by the salesperson column.

1.  Click a cell in the list.

2.  On the Data menu, click Subtotals.

3.  In the at each change in box, click the column that contains the groups for which you want subtotals. This should be the same column by which you sorted your list in step

4.  In the Use function box, click the function you want to use to calculate the subtotals. For information about the summary functions, click

5.  In the Add subtotal to box, select the check boxes for the columns that contain the values for which you want subtotals.

You also can "nest," or insert, subtotals for smaller groups within subtotal groups. You can remove subtotals from a list without affecting your original data.

You can use any of the following functions to summarize data in a list. Click the function you want in the Use function box in the Subtotal dialog box (Data menu, Subtotals command).

 Use this function
 To summarize
 Sum
 The sum of the values in a list. This is the default function for numeric data.
 Count
 The number of items in a list. This is the default function for nonnumeric data.
 Average
 The average of the values in a list.
 Max
 The largest value in a list.
 Min
 The smallest value in a list.
 Product
 The result of multiplying all the values in a list.
 Count Nums
 The number of records or rows in a list that contain numeric data.
 StdDev
 An estimate of the standard deviation of a population, where the list is the sample.
 StdDevp
 The standard deviation of a population, where the list is the entire population.
 Var
 An estimate of the variance of a population, where the list is the sample.
 Varp
 The variance of a population, where the list is the entire population.

To "nest," or insert, subtotals for smaller groups within existing subtotal groups, you must first sort the list.

Sort the list by two or more columns for which you want to calculate subtotals. For example, to summarize units sold by region and by salesperson within each region, first sort the list by the region column, and then sort by the salesperson column. When Microsoft Excel inserts subtotals, the salesperson subtotal values are nested within the subtotal values for the region.

Insert automatic subtotals for the first column for which you want subtotals. This column should be the column you specified in the Sort by box when the list was sorted. (In the example given in step 1, the region column would be the first column.)  After you have displayed automatic subtotals for the first column, repeat the process for the next column.

1.  Click a cell in the list.

2.  On the Data menu, click Subtotals.

3.  In the At each change in box, select the next column you want to subtotal.

4.  Clear the Replace current subtotals check box, and then click OK.

Repeat steps 4 through 7 for each column for which you want to calculate subtotals.

When you remove subtotals from a list, Microsoft Excel also removes the outline and all page breaks that were inserted into the list when you inserted the subtotals.

1.  Click a cell in the list that contains subtotals.

2.  On the Data menu, click Subtotals.

3.  Click Remove All.

When data is in list form, Microsoft Excel can create an outline to let you hide or show levels of detail with a single mouse click. An outline lets you quickly display only the rows or columns that provide summaries or headings for sections of your worksheet, or display the areas of detail data adjacent to a summary row or column.

Displaying and hiding detail data   An outline can have up to eight levels of detail, with each inner level providing details for the preceding outer level. In the following example, the row containing the grand total of all the rows is level 1, the rows containing totals for the South and West regions are level 2, and the detail rows for the regions are level 3. To display only the rows for a particular level, you can click the number for the level you want to see. The detail rows for the West region are hidden, but you can click the + outline symbols to display the detail rows.

To show                                                Click

The detail data within a The show detail symbol group

A specific level in an outline The row or column level symbol

All detail in an outline                The symbol for the lowest row and column level. For example, if there are three levels, click

Inserting automatic subtotals also creates an outline   If you use the Subtotal command (Data menu) to add subtotals to a list organized in rows, Excel outlines the worksheet so that you can show or hide as much detail as you need.

Outlining a worksheet automatically   If you have summarized data by using formulas that contain functions, such as SUM, Excel can automatically outline the data, as in the preceding example. The summary data must be adjacent to the detail data.

Outlining a worksheet manually   If the data is not organized so that Excel can outline it automatically, you can create an outline manually. For example, you'll need to manually outline data if the rows or columns of summary data contain values instead of formulas, such as in the example below. If you want to hide the detail rows for April and May, you can do so by outlining the list manually.

Because the totals in this list were typed as numbers, not calculated as formulas, automatic outlining won't work.

## Show or hide detail data in an outline

If you do not see the outline symbols on the worksheet, select the Outline symbols check box on the View tab of the Options dialog box (Tools menu).

 To hide
 Click
 The detail data within a group
 Row               level               bar                      Column            level     bar        Click anywhere on the level bar or the hide detail symbol .
 A specific level in an outline
 The preceding row or column level symbol . For example, if an outline has four levels, you can hide the fourth level by clicking .
 All detail in an outline
 The first level symbol    .

On the Tools menu, click Options, and then click the View tab.

To display the outline symbols, select the Outline symbols check box.  To hide the symbols, clear the check box.

Make sure the worksheet is organized in a hierarchical fashion and that all summary formulas in the area that you want to outline are located in the same direction relative to the detail data. That is, all summary columns must be either to the right or to the left of the detail data, but not mixed. All summary rows must be either below or above, but not mixed.

Select the range of cells you want to outline

To outline the entire worksheet, click any cell on the worksheet.

On the Data menu, point to Group and Outline, and then click Auto Outline.

Make sure that the summary rows or columns in all areas that you want to outline are located in the same direction relative to the detail data. That is, all summary columns must be either to the right or to the left of the detail data, but not mixed. All summary rows must be either below or above, but not mixed.

Select the rows or columns that contain detail data.

Detail rows or columns are usually adjacent to the row or column that contains the related summary data. For example, if Row 6 contains totals for Rows 3 through 5, select Rows 3 through 5.

On the Data menu, point to Group and Outline, and then click Group.

The outline symbols appear beside the group on the screen.

Continue to select detail rows or columns and click the Group command until you have created all of the levels you want in the outline.

Note   Microsoft Excel assumes by default that summary rows are below detail rows and summary columns are to the right of detail columns. If the summary rows or columns are otherwise, you can change this setting before you outline the data. On the Data menu, point to Group and Outline, click Settings, and then change the check boxes in the Direction group.

Select the rows or columns you want to ungroup.

On the Data menu, point to Group and Outline, and then click Ungroup.

Note   When you ungroup rows or columns in an outline that has several levels, the rows or columns become part of a higher-level group. For example, if you ungroup a level-3 group, it becomes a level-2 group. Continue ungrouping the selection until it's at the level you want.

Tip   To select a specific group of data within an outline, hold down SHIFT, and then click the show detail symbol  +  or the hide detail symbol  - or the level bar of the outline section.

When you remove an outline, the data on the worksheet does not change.

1.  Click any cell on the worksheet.

2.  On the Data menu, point to Group and Outline, and then click Clear Outline.

A consolidation rolls up the data from several worksheets.

Use 3-D references to combine data   When the source worksheets have different layouts and different data labels, or you want to create a custom layout or use custom summary formulas for a consolidation, use 3-D references. 3-D references are updated automatically whenever the source data changes.

In the following example, the formula in cell A2 adds three numbers that are located in different positions on three different worksheets.

Add data to a consolidation   When all of your source worksheets have the same layout, you can use a range of sheet names in 3-D formulas. To add another worksheet to the consolidation, just move the sheet into the range your formula refers to.

You can consolidate data in four ways:

By using 3-D references, the preferred method When you use 3-D references, there are no restrictions on the layout of the data in the source areas.

By position   Consolidate by position when the data in all source areas is arranged in identical order and location; for example, to combine data from a series of worksheets created from the same template.

By category   Consolidate by category when you want to summarize a set of worksheets that have the same labels but organize the data differently. This method combines data that has matching labels from each worksheet.

By creating a PivotTable report   This method is similar to consolidating by category but offers more flexibility to reorganize the categories.

1.  Click the upper-left cell of the destination area for the consolidated data.

2.  On the Data menu, click Consolidate.

In the Function box, click the summary function you want Microsoft Excel to use to consolidate the data. For information about the available summary functions, click  In the Reference box, enter a source area you want to consolidate.

Repeat steps 4 and 5 for each source area to consolidate.

To update the consolidation table automatically when the source data changes, select the Create links to source data check box.  To create links, the source and destination areas must be on different worksheets. Once you create links, you cannot add new source areas or change the source areas that are included in the consolidation.

Note   When you consolidate by position, Microsoft Excel does not copy the category labels in the source areas to the destination area. If you want labels for the destination worksheet, copy them or enter them manually.

1.  Click the upper-left cell of the destination area for the consolidated data.

2.  On the Data menu, click Consolidate.

3.  In the Function box, click the summary function you want Microsoft Excel to use to consolidate the data.

4.  In the Reference box, enter a source area you want to consolidate. Make sure to include the data labels in the selection.

Repeat steps 4 and 5 for each source area you want to consolidate.

Under Use labels in, select the check boxes that indicate where the labels are located in the source area: either the top row, the left column, or both.

To update the consolidation table automatically when the source data changes, select the Create links to source data check box.

To create links, the source and destination areas must be on different worksheets. Once you create links, you cannot add new source areas or change the source areas that are included in the consolidation.

Note :  Labels in a source area that do not match any labels in the other source areas result in separate rows or columns when you consolidate data.

When you consolidate data, you specify the source areas of the data either in 3-D formulas or in the Reference box of the Consolidate dialog box (Data menu, Consolidate command). The source areas can be cell ranges on the same worksheet as the consolidation table, on different worksheets in the same workbook, or in different workbooks or Lotus 1-2-3 files.

Name your source areas   To make source areas easy to keep track of, name each range and use the names in the Reference box.

On the same worksheet   When the source areas and destination area are on the same worksheet, use cell or range references or names.

On different worksheets   When the sources and destination are on different worksheets, use sheet and cell or range references or names. For example, to include a range named Budget from the Marketing worksheet in a consolidation on the Summary worksheet, enter Marketing!Budget.

In different workbooks   When the sources and destination are in different workbooks, use book, sheet, and cell or range references or names. For example, to include a range named Sales from the Eastern Region worksheet in the 1996 workbook in the same folder, enter the following:

'[]Eastern Region'!Sales

In different storage locations   When the sources and destination are in different workbooks in different locations, use the full path, book, sheet, and cell or range references or names. For example, to include a range named Revenue from the February worksheet in the Sales Department workbook in the Budget Worksheets folder, enter the following:

'[C:\Budget Worksheets\Sales ] February’! Revenue

Note   You can omit the sheet names from the references if your workbook has names that you assigned, rather than labels used as names by Microsoft Excel. For example, '[]'!Sales or '[C:\Budget Worksheets\Sales ]'!Revenue.

Tip   To enter a source reference without typing, click in the Reference box, and then select the source area. To select a source area in another workbook, click Browse. To clear the Consolidate dialog box out of the way temporarily while you select the source area, click Collapse Dialog .

If the worksheet that contains the destination area also contains an outline or has been used previously for a linked consolidation, do not create new links without first removing the outline, if the worksheet has one, or deleting the old consolidation table.

1.  Click the upper-left cell in the consolidation table.

2.  On the Data menu, click Consolidate.

3.  Select the Create links to source data check box.

Note   The consolidation table must be on a different worksheet from the source areas.

A PivotTable report is an interactive table that you can use to quickly summarize large amounts of data. You can rotate its rows and columns to see different summaries of the source data, filter the data by displaying different pages, or display the details for areas of interest.

An example of a simple PivotTable report. The source data is in the list on the left.

When to use a PivotTable report   Use a PivotTable report when you want to compare related totals, especially when you have a long list of figures to summarize and you want to compare several facts about each figure. Use PivotTable reports when you want Microsoft Excel to do the sorting, subtotaling, and totaling for you. In the example above, you can easily see how the third-quarter golf sales in cell F5 stack up against sales for another sport or quarter, or grand total sales. Because a PivotTable report is interactive, you or other users can change the view of the data to see more details or calculate different summaries.

Fields and items   A PivotTable report contains fields, each of which corresponds to a column (or OLAP dimension) in the source data and summarizes multiple rows of information from the source data. Fields in a PivotTable report list items of data across rows or down columns. The cells where the rows and columns intersect show summarized data for the items at the top of the column and the left side of the row.

In this PivotTable report, the Product field contains the items Dairy and Meat.

Data fields and cells   A data field, such as Sum of Sales, provides the values that are summarized in the PivotTable report. In the example, cell C6 shows the total for Davolio's May dairy sales — that is, the sum of the sales figures from every row in the source data that contains May for the month, Davolio for the salesperson, and Dairy for the product.

Summary functions   To summarize the data field values, PivotTable reports use summary functions, such as Sum, Count, or Average. These functions also provide subtotals and grand totals automatically, where you choose to show them. In this example, the data from the Sales column in the source list is summarized with Sum, showing subtotals for the months and grand totals for the rows and columns. For OLAP source data, the OLAP server provides precalculated summary functions.

Viewing details   In most PivotTable reports, you can view the detail rows from the source data that make up the summary value in a particular data cell. OLAP source data is not organized in rows that you can view in this way, but you can change the level of detail displayed in the entire PivotTable report when it's based on OLAP source data.

Changing the layout   By dragging a field button to another part of the PivotTable report, you can view your data in various ways and calculate different summarized values. For example, you can view the names of salespersons across the columns instead of down the rows

An example of a default PivotTable report

Row fields   Fields from the underlying source data that are assigned a row orientation in a PivotTable report. In the preceding example, Product and Sold By are row fields. A PivotTable report that has more than one row field has one inner row field (Sold By, in the example), the one closest to the data area. Any other row fields are referred to as outer row fields. Inner and outer row fields have different attributes. Items in the outermost field are displayed only once, but items in the rest of the fields are repeated as needed.

Column field   A field that's assigned a column orientation in a PivotTable report. In the preceding example, Quarters is a column field with two items, Qtr2 and Qtr3. A PivotTable report can have multiple column fields just as it can have multiple row fields. Most indented format PivotTable reports do not have column fields.

Item   A subcategory, or member, of a PivotTable field. In the preceding example, Dairy and Meat are items in the Product field. Items represent unique entries in the same field, or column, in the source data. Items appear as row or column labels or in the drop-down lists for page fields.

Page field   A field that's assigned to a page, or filter, orientation. In the example, Region is a page field that you can use to filter the report by region. With the Region field, you can display summarized data for only the East region, for only the West region, or for other regions. When you click a different item in a page field, the entire PivotTable report changes to display only the summarized data associated with that item.

Page field item   Each unique entry or value from the field, or column, in the source list or table becomes an item in the page field list. In the example, East is the currently selected item for the Region page field, and the PivotTable report displays the summarized data for only the East region.

Data field   A field from a source list or database that contains data to be summarized. In the example, Sum of Sales is a data field that summarizes the entries from the Sales field, or column, in the source data. In the indented-format report example, this field is named Sales instead of Sum of Sales.

A data field usually summarizes numeric data, such as statistics or sales figures, but the underlying data can also be text. By default, Microsoft Excel summarizes text data in PivotTable reports by using the Count summary function and summarizes numeric data by using Sum.

Data area   The part of a PivotTable report that contains summary data. The cells of the data area show summarized data for the items in the row and column fields. Each value in the data area represents a summary of data from the source records, or rows. In the preceding example, the value in cell C6 is a summary of Dodsworth's secondquarter dairy sales — that is, a summary of the sales figures for every record, or row, in the source data that contains the items Dairy, Dodsworth, and Qtr2. In the indentedformat report example, this information is shown in cell D7.

Field drop-down arrow   The arrow at the right side of each field. Click this arrow to select the items that you want to show.

Open the workbook where you want to create the PivotTable report.

If you are basing the report on a Microsoft Excel list or database, click a cell in the list or database.

1.  On the Data menu, click PivotTable and PivotChart Report.

2.  In step 1 of the PivotTable and PivotChart Wizard, follow the instructions, and click PivotTable under What kind of report do you want to create?

3.  Follow the instructions in step 2 of the wizard.

4.  In step 3 of the wizard, determine whether you need to click Layout. Do one of the following:

•   If you clicked Layout in step 3, after you lay out the report in the wizard, click OK in the PivotTable and PivotChart Wizard

Layout dialog box, and then click Finish to create the report.

•   If you did not click Layout in step 3, click Finish, and then lay out the report on the worksheet.

Use this procedure after you click Layout in step 3 of the PivotTable and PivotChart Wizard.

From the group of field buttons on the right, drag the fields that you want onto the ROW and COLUMN areas in the diagram.

In PivotTable reports, row field and item labels appear on the left. Column field and item labels appear across the top. In PivotChart reports, row field items are plotted on the category axis,and column field items are plotted as data the fields that contain the data that you want to summarize onto the DATA area. In PivotChart reports, data fields determine the values for the value axis. For OLAP source data, only fields identified by at the beginning of the row on the toolbar can be used for data fields. These fields appear at the bottom of the group of field buttons.

For PivotTable or PivotChart reports that are based on excel list you can use a different summary function for a data field. If you want to do this, double-click the field in the DATA area, click the function that you want in the Summarize by list, and then click OK

To include a data field more than once so you can select an additional summary function, drag the field onto the DATA area a second time.  Drag fields that you want to use as page fields onto the PAGE area.

By default, Microsoft Excel retrieves data for all page fields items at once. To have page fields retrieve data separately for each item, double-click each field in the PAGE area, click Advanced, click Query external data source as you select each page field item, and then click OK twice.

To rearrange fields, drag them from one area to another. To remove a field, drag it out of the diagram. When you are satisfied with the layout, click OK, and then click Finish.

There are two ways to rearrange the fields after Excel creates the report. You can try rearranging the fields on the worksheet or you can click the finished PivotTable report (or the associated PivotTable report for a PivotChart report), click PivotTable Wizard on the PivotTable toolbar to return to step 3, and then click Layout

1.  Click the PivotTable report.

2.  On the PivotTable toolbar,click PivotTable, point to Select, and then click Entire Table.

3.  On the Edit menu, point to Clear, and then click all.

A data table is a range of cells that shows how changing certain values in your formulas affects the results of the formulas. Data tables provide a shortcut for calculating multiple versions in one operation and a way to view and compare the results of all of the different variations together on your worksheet.

One-variable data tables   For example, use a one-variable data table if you want to see how different interest rates affect a monthly mortgage payment. In the following example, cell D2 contains the payment formula, =PMT(B3/12,B4,-B5), which refers to the input cell B3.

Two-variable data tables   A two-variable data table can show how different interest rates and loan terms will affect the mortgage payment. In the following example, cell C2 contains the payment formula, =PMT(B3/12,B4,-B5), which uses two input cells, B3 and B4.

You must design one-variable data tables so that input values are listed either down a column (column-oriented) or across a row (row-oriented). Formulas used in a onevariable data table must refer to an input cell.

Type the list of values you want to substitute in the input cell either down one column or across one row.

If the input values are listed down a column, type the formula in the row above the first value and one cell to the right of the column of values. Type any additional formulas to the right of the first formula.

If the input values are listed across a row, type the formula in the column to the left of the first value and one cell below the row of values. Type any additional formulas below the first formula.

Select the range of cells that contains the formulas and values you want to substitute. On the Data menu, click Table.

If the data table is column-oriented, type the cell reference for the input cell in the Column input cell box.

If the data table is row-oriented, type the cell reference for the input cell in the Row input cell box.

Formulas used in a one-variable data table must refer to the same input cell. If the input values are listed down a column, type the new formula in a blank cell to the right of an existing formula in the top row of the table.

If the input values are listed across a row, type the new formula in a blank cell below an existing formula in the first column of the table.

Select the data table, including the column or row that contains the new formula. On the Data menu, click Table.

If the input values are in a column, enter the reference for the input cell in the Column input cell box.

If the input values are in a row, enter the reference for the input cell in the Row input cell box.

You cannot convert an individual value. Because the resulting values are in an array, you must convert all of the values to constant values.

Select all resulting values in the data table.

1.  On the Edit menu, click Copy.

2.  On the Edit menu, click Paste Special.

3.  Under Paste, click Values.

Two-variable data tables use only one formula with two lists of input values. The formula must refer to two different input cells.

In a cell on the worksheet, enter the formula that refers to the two input one list of input values in the same column, below the formula. Type the second list in the same row, to the right of the formula.

Select the range of cells that contains the formula and both the row and column of values.

1.  On the Data menu, click Table.

2.  In the Row input cell box, enter the reference for the input cell for the input values in the row.

3.  In the Column input cell box, enter the reference for the input cell for the input values in the column.

When you know the desired result of a single formula but not the input value the formula needs to determine the result, you can use the Goal Seek feature. When goal seeking, Microsoft Excel varies the value in one specific cell until a formula that's dependent on that cell returns the result you want.

For example, use Goal Seek to change the interest rate in cell B3 incrementally until the payment value in B4 equals \$900.00.

1.  On the Tools menu, click Goal Seek.

2.  In the Set cell box, enter the reference for the cell that contains the formula you want to resolve.

3.  In the To value box, type the result you want.

4.  In the By changing cell box, enter the reference for the cell that contains the value you want to adjust. This cell must be referenced by the formula in the cell you specified in the Set cell box.

A scenario is a set of values that Microsoft Excel saves and can substitute automatically in your worksheet. You can use scenarios to forecast the outcome of a worksheet model. You can create and save different groups of values on a worksheet and then switch to any of these new scenarios to view different results.

Creating scenarios   For example, if you want to create a budget but are uncertain of your revenue, you can define different values for the revenue and then switch between the scenarios to perform what-if analyses.

In the example above, you could name the scenario Worst Case, set the value in cell B1 to \$50,000, and set the value in cell B2 to \$13,200.

You could name the second scenario Best Case and change the values in B1 to \$150,000 and B2 to \$26,000.

Scenario summary reports   To compare several scenarios, you can create a report that summarizes them on the same page. The report can list the scenarios side by side or summarize them in a PivotTable report.

1.  On the Tools menu, click Scenarios.

3.  In the Scenario name box, type a name for the scenario.

4.  In the Changing cells box, enter the references for the cells that you want to change.

5.  Under Protection, select the options you want.

6.  Click OK.

7.  In the Scenario Values dialog box, type the values you want for the changing cells.

8.  To create the scenario, click OK.

9.  To create additional scenarios, click Add, and then repeat steps 3-7. When you finish creating scenarios, click OK, and then click Close in the Scenario Manager dialog box.

Tip   To preserve the original values for the changing cells, create a scenario that uses the original cell values before you create scenarios that change the values.

When you display a scenario, you change the values of the cells saved as part of that scenario.

1.  On the Tools menu, click Scenarios.

2.  Click the name of the scenario you want to display.

3.  Click Show.

If you keep the original name of a scenario after you make changes to it, the new values for changing cells replace the values in the original scenario.

On the Tools menu, click Scenarios.

1.  Click the name of the scenario you want to edit, and then click Edit.

2.  Make the changes you want.

3.  In the Scenario Values dialog box, type the values you want for the changing cells.

4.  To save the changes, click OK.

To return to the Scenario Manager dialog box without changing the current scenario, click Cancel

1.  On the Tools menu, click Scenarios.

2.  Click Summary.

Click Scenario summary or Scenario PivotTable.

In the Result cells box, enter the references for the cells that refer to cells whose values are changed by the scenarios. Separate multiple references with commas.

You can also determine resulting values when you need to change more than one cell used in a formula and have multiple constraints for those values. Solver adjusts the values in the cells you specify to produce the result you want from the formula.

For example, use Solver to maximize the profit shown in cell F7 by changing the quarterly advertising budget (cells B5:E5) while limiting the total advertising budget (cell F5) to \$40,000.

With Solver, you can find an optimal value for a formula in one cell — called the target cell — on a worksheet. Solver works with a group of cells that are related, either directly or indirectly, to the formula in the target cell. Solver adjusts the values in the changing cells you specify — called the adjustable cells — to produce the result you specify from the target cell formula. You can apply constraints to restrict the values Solver can use in the model, and the constraints can refer to other cells that affect the target cell formula.

On the Tools menu, click Solver.

1.  If the Solver command is not on the Tools menu, you need to install the Solver add-in.

In the Set Target Cell box, enter a cell reference or name for the target cell. The target cell must contain a formula.

To have the value of the target cell be as large as possible, click Max.

2.  To have the value of the target cell be as small as possible, click Min

3.  To have the target cell be a certain value, click Value of, and then type the value in the box.

In the By Changing Cells box, enter a name or reference for each adjustable cell, separating nonadjacent references with commas. The adjustable cells must be related directly or indirectly to the target cell. You can specify up to 200 adjustable cells.

4.  To have Solver automatically propose the adjustable cells based on the target cell, click Guess

5.  In the Subject to the Constraints box, enter any constraints  you want to apply.

6.  Click Solve.

7.  To keep the solution values on the worksheet, click Keep Solver Solution in the Solver Results dialog box.

8.  To restore the original data, click Restore Original Values

1.  On the Tools menu, click Solver.

3.  In the Cell Reference box, enter the reference or name of the cell range for which you want to constrain the value.

4.  Click the relationship ( <=, =, >=, Int, or Bin ) that you want between the referenced cell and the constraint. If you click Int, "integer" appears in the Constraint box. If you click Bin, "binary" appears in the Constraint box.

5.  In the Constraint box, type a number, a cell reference or name, or a formula.

To accept the constraint and return to the Solver Parameters dialog box, click OK

Cell reference

Specifies the cell or range of cells where you want to constrain the values.

Constraint

Specifies a restriction on the contents of the Cell reference box. Select the relationship you want to add or change ( <=, =, >=, Int, or Bin ) between the referenced cell and the constraint. Then enter the constraint — a number, cell or range reference, or formula — in the box to the right.

Click to add another constraint without returning to the Solver Parameters dialog box.

When Solver reaches a solution, it displays one of the following two messages in the Solver Results dialog box:

Solver found a solution. All constraints and optimality conditions are satisfied.

All constraints within the precision setting in the Solver Options dialog box are satisfied, and when appropriate, a local maximum or minimum value has been found for the target cell.

Solver has converged to the current solution. All constraints are satisfied.

The relative change in the target cell is less than the Convergence setting in the Solver Options dialog box for the last five trial solutions. If you provide a smaller value for the Convergence setting, Solver could try for a better solution but would take more solution time.

When Solver cannot reach an optimal solution, it displays one of the following messages in the Solver Results dialog box:

Solver cannot improve the current solution. All constraints are satisfied.

Only an approximate solution has been found, but the iterative process cannot find a better set of values than those displayed. Either further accuracy is not achievable, or the precision setting is too low. Try changing the precision setting in the Solver Options dialog box to a larger number, and then run the problem again.

Stop chosen when the maximum time limit was reached.

The maximum amount of time has elapsed without finding a satisfactory solution. To save the values found so far and also save future recalculation time, click Keep Solver Solution or Save Scenario

Stop chosen when the maximum iteration limit was reached.

The maximum number of iterations has been reached without finding a satisfactory solution. Increasing the number of iterations might help, but you should examine the final values for insights into the problem. To save the values found so far and also save future recalculation time, click Keep Solver Solution or Save Scenario

The Set Target Cell values do not converge.

The value for the target cell is increasing (or decreasing) without bound, even though all constraints are satisfied. You might have omitted one or more constraints in setting up the problem. Check the current worksheet values to see how the solution is diverging, check the constraints, and then run the problem again.

Solver could not find a feasible solution.

Solver could not find a trial solution that satisfies all constraints within the precision setting. It is likely that the constraints are inconsistent. Examine the worksheet for a possible mistake in the constraint formulas or in the choice of constraints.

Solver stopped at user's request.

You clicked Stop in the Show Trial Solution dialog box, either after interrupting the solution process or when stepping through trial solutions.

The conditions for Assume Linear Model are not satisfied.

You selected the Assume linear model check box, but the final calculations in Solver yield values that do not agree with the linear model. The solution is not valid for the actual worksheet formulas. To check whether the problem is nonlinear, select the Use automatic scaling check box, and run the problem again. If you see this message again, clear the Assume linear model check box, and then run the problem again.

Solver encountered an error value in a target or constraint cell.

One or more formulas yielded an error value on the latest calculation. Find the target or constraint cell that contains the error, and change its formula to yield an appropriate numeric value.

You typed an invalid name or formula in the Add Constraint or Change Constraint dialog box, or you typed "integer" or "binary" in the Constraint box. To constrain a value to an integer, click Int in the list of comparison operators. To set a binary constraint, click Bin

1.  Define a problem.

2.  In the Solver Parameters dialog box, click Options.

3.  To see the values of each trial solution, select the Show Iteration Results check box, click OK, and then click Solve.

4.  Solver enters the values for the first trial solution on the worksheet and displays the Show Trial Solution dialog box.

5.  To stop the solution process and display the Solver Results dialog box, click Stop.

a. To continue the solution process and display the next trial solution, click Continue

Select the cells that you want to restrict.

On the Data menu, click Validation, and then click the Settings tab. In the Allow box, click the type of data.

To specify only numbers, click Whole Number or Decimal

To specify only dates or times, click Date or Time

Click the operator you want in the Data box, and then specify the upper or lower limit for the data, or both limits, depending on the operator you select. You can enter values, cell references, or formulas for the limits.

If you want to allow the cell that you're restricting to be blank, or you set limits that use a cell reference or formula that depends on cells that are initially blank, make sure Ignore blank is selected.

To enforce the restrictions you set for blank cells, treating these cells as if they contain zeros, clear the Ignore blank check box.

To display messages to prompt for entries and to explain or prevent incorrect entries, specify the types of messages you want on the Input Message and Error Alert tabs.  To omit display of messages, clear the Show input message when cell is selected check box on the Input Message tab, and clear the Show error alert after invalid data is entered check box on the Error Alert tab.

When you specify the type of allowable data, the cell formatting is not affected. To format the cells as numbers, dates, or times, click Cells on the Format menu, and then click the Number tab. Select the format you want in the Category box, and then select any options you want.

A formula for a limit can evaluate data only on the worksheet where you set up the restrictions. To use data in other worksheets or workbooks in a formula, enter a reference to the external data in a cell on the active worksheet, or define a name for the external data on the active worksheet. The formula can then refer to the cell or name on the same worksheet. For example, if the data you want to use in a formula is in cell A6 on the first worksheet in a workbook named , you could define the name ValidData on the active worksheet to be =[]Sheet1!\$A\$6 and then enter a reference =ValidData when you specify the limits for the data. For

information about defining names, click .

You cannot use array constants in data restriction formulas.

1.  On the same worksheet, type the list of valid entries down a single column or across a single row. Do not include blank cells in the list.

2.  Select the cells that you want to restrict.

3.  On the Data menu, click Validation, and then click the Settings tab.

4.  In the Allow box, click List.

5.  In the Source box, enter a reference to your list of valid data.  If you want to select from a list of the entries when you click a restricted cell, make sure the In-cell dropdown check box is selected.

To specify that the entry is not valid if the restricted cells or the cells that contain your list of valid data are blank, clear the Ignore blank check box.

To display messages to prompt for entries and to explain or prevent incorrect entries, specify the types of messages you want on the Input Message and Error Alert tabs

To omit display of messages, clear the Show input message when cell is selected check box on the Input Message tab, and clear the Show error alert after invalid data is entered check box on the Error Alert tab.

If the list of valid entries is short, you can type them in the Source box instead of typing the entries on a worksheet, separated by the Windows list separator character (commas by default). For example, you could type Low, Average, High in the Source box instead of entering the three words on a worksheet.

If the list of valid entries might change, name the list range, and then enter the name in the Source box. When the named range grows or shrinks because of changes you make to the list on the worksheet, the list of valid entries for the cell automatically reflects the changes.

If the list of valid entries is in another worksheet or workbook, define a name for the external data on the active worksheet. In the Source box, you can then refer to the name on the same worksheet. For example, if the list of valid entries is in cells A6:A12 on the first worksheet in a workbook named , you could define the name ValidData on the active worksheet to be =[]Sheet1!\$A\$6:\$A\$12 and then enter =ValidData in the Source box.

1.  Select the cells that you want to restrict.

2.  On the Data menu, click Validation, and then click the Settings tab.

3.  In the Allow box, click Text Length.

4.  Click the operator you want in the Data box, and then specify the upper or lower limit, or both limits, depending on the operator you select. You can enter values, cell references, or formulas for the limits.

If you want to allow the cell that you're restricting to be blank, or you set limits that use a cell reference or formula that depends on cells that are initially blank, make sure Ignore blank is selected.

To enforce the restrictions you set for blank cells, treating these cells as if they contain zeros, clear the Ignore blank check box.

To display messages to prompt for entries and to explain or prevent incorrect entries, specify the types of messages you want on the Input Message and Error Alert tabs.  To omit display of messages, clear the Show input message when cell is selected check box on the Input Message tab, and clear the Show error alert after invalid data is entered check box on the Error Alert tab.

To specify that a cell must contain text without placing any restrictions on the number of characters, select greater than or equal to in the Data box, and then type 0 (zero) in the Minimum box.

When you set the text length, the cell formatting is not affected. To format the cells as text, click Cells on the Format menu, and then click the Number tab. In the Category box, select Text.

A formula for a limit can evaluate data only on the worksheet where you set up the restrictions. To use data in other worksheets or workbooks in a formula, enter a reference to the external data in a cell on the active worksheet, or define a name for the external data on the active worksheet. The formula can then refer to the cell or name on the same worksheet. For example, if the data you want to use in a formula is in cell A6 on the first worksheet in a workbook named , you could define the name ValidData on the active worksheet to be =[]Sheet1!\$A\$6 and then enter a reference to ValidData when you specify the limits for the data.

If you use a formula to enter data in a cell with a restricted text length, Microsoft Excel checks the length of the result, not the length of the formula. For example, if the length is restricted to a minimum of three characters, and you enter =20+50 in the cell, the result, 70, would be two characters and therefore would not be valid. You cannot use array constants in data restriction formulas.

1.  Select the cells that you want to restrict.

2.  On the Data menu, click Validation, and then click the Settings tab.

3.  In the Allow box, click Custom.

4.  In the Formula box, enter a formula that calculates a logical value (TRUE or FALSE). Entries for the cell are invalid when the formula calculates a value of FALSE. Start the formula with an equal sign (=).

For example, on a worksheet that calculates profit by subtracting the total of the expense entries from the total revenue calculation, you might have a goal of keeping the profit above a certain percentage of expenses. For cells D6:D13, where you enter each expense, you could determine the valid entries with a formula such as =Profit > SUM(D6:D13) * 15%, where Profit would be a named cell.

If you want to allow the cell that you're restricting to be blank, or your formula depends on cells that are initially empty, make sure Ignore blank is selected.  To enforce the restrictions you set for blank cells, treating these cells as if they contain zeros, clear the Ignore blank check box.

To display messages to prompt for entries and to explain or prevent incorrect entries, specify the types of messages you want on the Input Message and Error Alert tabs.

To omit display of messages, clear the Show input message when cell is selected check box on the Input Message tab, and clear the Show error alert after invalid data is entered check box on the Error Alert tab.

Notes

Before evaluating the formula, Microsoft Excel recalculates the worksheet with the data entered in the cell.

A data restriction formula can evaluate data only on the worksheet where you set up the restrictions. To use data in other worksheets or workbooks in a formula, enter a reference to the external data in a cell on the active worksheet, or define a name for the external data on the active worksheet. The formula can then refer to the cell or name on the same worksheet. For example, if the data you want to use in a formula is in cell A6 on the first worksheet in a workbook named , you could define the name ValidData on the active worksheet to be =[]Sheet1!\$A\$6 and then enter a reference to ValidData in your formula. For information about defining names, click

You cannot use array constants in data restriction formulas.

If you choose a value other than Custom in the Allow box, your data restriction formulas must evaluate to a number.

When you audit a worksheet for incorrect entries, Microsoft Excel identifies all cells that contain values that are outside the limits you set by using the Validation command on the Data menu, including values that were typed, copied, or filled in the cells, values that became incorrect because of calculations in formulas, and values placed in cells by macros

Make sure the Auditing toolbar is displayed by pointing to Auditing on the Tools menu, and then making sure the Show Auditing Toolbar command is checked.

On the Auditing toolbar, click Circle Invalid Data

If the worksheet has more than 255 cells that contain invalid data, Microsoft Excel circles only 255 of the cells. To circle more cells, correct some of the invalid cells, and then click Circle Invalid Data again.

If you are using the manual calculation option, and you set up restrictions that involve calculations using the entry, you may see a message that requires you to recalculate the worksheet when you identify incorrect entries. To avoid seeing this message, click Options on the Tools menu, and then click the Calculation tab. Under Calculation, click Automatic.

Tip   To see what data restrictions and messages are in effect for a cell, click the cell, and then click Validation on the Data menu.

To find all cells that have the same data restrictions and messages, click a cell that has the data restrictions and messages you want to find.

To find every cell on the worksheet that has data restrictions or messages, click anywhere on the worksheet.

1.  On the Edit menu, click Go To.

2.  Click Special.

3.  Click Data validation.

To find every cell on the worksheet that has data restrictions or messages, click All.  To find only those cells with the same data restrictions and messages as the cell you clicked in step 1, click same.

Tip   To see what the data restrictions and messages are for a cell, click the cell, and then click Validation on the Data menu.

Select the cells for which you want to display a message.

On the Data menu, click Validation, and then click the Input Message tab.

Make sure the Show input message when cell is selected check box is selected.

To display a bold title in the message, type the text in the Title box.

Type the text of the message in the Input Message box, up to 255 characters. Press ENTER to start a new line in the message.

You must enter text in the Input Message box for the message to appear.

## Display a message when incorrect data is entered in a cell

Select the cells for which you want to display a message.

On the Data menu, click Validation, and then click the Settings tab.

Specify the data restrictions for which you want to display the message.

For Help on an option, click the question mark and then click the option.  Click the Error Alert tab.

Make sure the Show error alert after invalid data is entered check box is selected.

In the Style box, specify the type of message you want.

1.  To display an information message that has OK and Cancel buttons and has OK as the default button, click Information

2.  To display a warning message with the text "Continue?", followed by Yes, No, and Cancel buttons, with No as the default button, click Warning

3.  In both message types, the OK and Yes buttons enter the invalid data in the cell. The No button returns to the cell for further editing. The Cancel button restores the previous value to the cell.

4.  To display a stop message that has Retry and Cancel buttons, with Retry as the default button, click Stop

If you want a title to appear in the title bar of the message or in the Office Assistant balloon if the Office Assistant is displayed, type the text in the Title box. If you leave the Title box blank, the title defaults to Microsoft Excel.

If you want to display your own text for the message, type the text in the Error message box, up to 225 characters. Press ENTER to start a new line in the message. If you don't enter any text in the Error message box, the message displays the following: "The value you entered is not valid. A user has restricted values that can be entered into this cell."

Note   Microsoft Excel displays the message only when a user types data in the cell. Formulas that calculate to invalid data, data placed in the cell by a macro, and data that has been copied or filled in cells do not cause the error message to be displayed.

Select the cells for which you want to display a message and prevent incorrect entries.

On the Data menu, click Validation, and then click the Settings tab.

Specify the data restrictions for which you want to display the message.

For Help on an option, click the question mark and then click the option.  Click the Error Alert tab.

Make sure the Show error alert after invalid data is entered check box is selected. In the Style box, click Stop. The message will have a Retry button that returns to the cell for further editing and a Cancel button that restores the previous value in the cell. If you want a title to appear in the title bar of the message or in the Office Assistant balloon if the Office Assistant is displayed, type the text in the Title box. If you leave the Title box blank, the title defaults to Microsoft Excel.

If you want to display your own text for the message, type the text in the Error message box, up to 225 characters. Press ENTER to start a new line in the message. If you don't enter any text in the Error message box, the message displays the following: "The value you entered is not valid. A user has restricted values that can be entered into this cell."

Note   Microsoft Excel displays the message only when a user types data in the cell. Formulas that calculate to invalid data, data placed in the cell by a macro, and data that has been copied or filled do not cause the message to appear.

1.  Click the cell with the data restrictions and messages you want to copy, and click Copy

2.  Select the cells for which you want the same data restrictions and messages.

3.  On the Edit menu, click Paste Special.

4.  Click Validation.

If a cell in which you paste data restrictions already contains data that does not meet the restrictions, the existing data is not changed.

When you copy all cell contents by using the All or All except borders options of the Paste Special command or Paste Microsoft Excel also copies the data restrictions and messages.

If the workbook is shared, remove it from shared use.

1.  Click a cell for which you want to change the data restrictions or messages.

2.  On the Data menu, click Validation.

3.  On each tab, select and change the options you want.

If you want the changes to affect other cells on the worksheet that have the same restrictions and messages, select the Apply these changes to all other cells with the same settings check box on the Settings tab. If you want the changes to affect only the currently selected cell, clear this check box. While you are entering data into a cell that has data restrictions or messages, you cannot make changes to the restrictions or messages.

While a workbook is shared, you cannot make changes to the restrictions or messages by using the Data Validation dialog box. When you enter data in a shared workbook, restrictions you specified before sharing the workbook remain in effect, and messages you specified before sharing the workbook continue to be displayed.

If you unlock cells that have data restrictions or messages and then protect the contents of the worksheet, you can enter data and display the input and error messages, but you cannot make changes to the restrictions or messages by using the Data Validation dialog box.

Select the cells from which you want to remove data restrictions and messages. On the Data menu, click Validation, and then click the Settings tab. Click Clear All.

To find all cells that have the same data restrictions and messages, click a cell that has the data restrictions and messages you want to find.

To find every cell on the worksheet that has data restrictions or messages, click anywhere on the worksheet.

1.  On the Edit :Go To: Click Special.

2.  Click Data validation.

To find every cell on the worksheet that has data restrictions or messages, click All.  To find only those cells with the same data restrictions and messages as the cell you clicked in step 1, click Same.

Tip   To see what the data restrictions and messages are for a cell, click the cell, and then click Validation on the Data menu.

# Working with Excel Macros

An Excel macro is a series of commands that Microsoft Excel carries out as a unit. You can record your own macros to customize the way Microsoft Excel works for you. Any sequence of actions that you perform can be recorded. You can then play back the macro to repeat your recorded actions automatically. Once you record a macro, you can also assign it to a menu item or a button. Then running a macro is as simple as choosing the menu item or clicking the button.

## Recording a Macro

1.   From the menu bar, choose Tools, Record Macro, Record New Macro.

2.   In the Macro Name box, type a name for the macro. The name can contain letters, numbers, and underscores, but it cannot contain blank spaces or punctuation marks. The macro name must begin with a letter.

3.   In the Description box, type a description of the macro.

4.   Choose the OK button. The Macro Recorder starts recording all subsequent keystrokes and mouse actions. The Stop Macro button also appears on your screen on its own toolbar.

5.   Carry out the actions you want to record.

6.   Click the Stop Macro button. Alternatively, from the menu bar, choose Tools, Record Macro, Stop Recording.

1.   From the menu bar, choose Tools, Macro.

2.   In the Macro Name / Reference box, type or select a name.

3.   Choose the Run button.

Microsoft Excel provides a Visual Basic toolbar that you can display by choosing the Toolbars command from the View menu. You can use several of the buttons on this toolbar to record, run, and stop macros.

Run Macro   Record Macro

Visual Basic Editor

1.   From the menu bar, choose Tools, Macro.

2.   In the Macro Name/Reference box, type or select a macro name.

3.   Choose the Options button.

4.   Under Assign To, select the Menu Item On Tools Menu check box, and then type the command name, as you want it to appear on the Tools menu.

5.   Choose the OK button.

6.   Choose the Close button.

Ensure that the Drawing toolbar is displayed. If it is not, choose View from the menu bar, and then choose Toolbars, and select the Drawing toolbar to display.

1.   Click the Create Button button on the Drawing toolbar.

2.   Point to where you want one corner of the button.

3.   Drag until the button is the size and shape you want. When you release the mouse button, the Assign Macro dialog box appears.

4.   To assign an existing macro to the button, type or select the name of the macro in the Macro Name / Reference box, and then choose the OK button. Or, to assign a new macro to the button, choose the Record button, and then follow the steps for recording a macro.

1.   From the menu bar, choose View, Toolbars.

2.   To add the custom button to a new toolbar, select the text in the Toolbar Name box, type the name of the new toolbar, and then choose the new button. Or, to add the custom button to an existing toolbar, choose the Customize button.

3.   In the Categories box, select Custom.

4.   Drag the custom button from the box to any visible toolbar. The button is added wherever you position it on the toolbar, and the Assign Macro dialog box appears.

5.   To assign an existing macro to the custom button, type or select the name of the macro in the Macro Name / Reference box, and then choose the OK button. Or, to assign a new macro to the button, choose the Record button, and then follow the steps for recording a macro.

6.   If necessary, choose the Close button to close the Customize dialog box.

1.   Hold down CTRL, and then select the button.

2.   From the menu bar, choose Tools, Assign Macro.

3.   To assign an existing macro to the button, type or select the name of the macro in the Macro Name / Reference box, and then choose the OK button. Or, to clear the macro assigned to the button, delete the macro name from the Macro Name / Reference box, and then choose the OK button. Or, to assign a new macro to the button, choose the Record button, and then follow the steps for recording a macro.

One of the options that can be set at the time of recording a macro is the type of reference needed. A reference is the address of a cell in Microsoft Excel, such as A1 or C3. A reference is either absolute or relative.

When the reference type is set to absolute, Microsoft Excel keeps track of the exact position of each cell you select. When the reference type is set to relative, however, Microsoft Excel keeps track of the position of each cell you select relative to the previously selected cell.

The advantage of using relative reference is that you can run the resulting macro anywhere on your worksheet. With absolute references, on the other hand, you can run your macro on the same cells no matter where you are on the worksheet.

To set the reference type:

•   From the menu bar, choose Tools, Record Macro, Use Relative References.

Another option you can set when you choose the Options button in the Record New

Macro dialog box (which is displayed by choosing Record Macro and then Record New Macro from the Tools menu) specifies where to store the macro you are recording -- in the active workbook, in a new workbook, or in the Personal Macro Workbook.

The Personal Macro Workbook is a hidden workbook that is always open, unless you specify otherwise. Since this workbook is always open, the macros you store in it are always available. The macro names appear in the Macro dialog box, and the macro shortcut keys are available.

To display the Personal Macro Workbook:

1.   Choose Window from the menu bar, and then choose Unhide.

2.   Select .

•   Plan what you want to do before you begin recording. Remember, the Macro Recorder records everything you do, including your mistakes.

•   Switch to the appropriate workbook and select the appropriate sheet before you turn on the recorder.

•   Select cells of objects first, and then turn on the recorder. This makes your macro portable, i.e., applicable to whatever the active selection is when you run the macro. An exception to this point should be made when you want to run a macro on the same cell every time.

•   Use the Macro Recorder as a learning tool for more Visual Basic commands.

Microsoft Excel provides a number of built-in functions that you can use in your worksheets, such as Sum, VLookUp, etc. In addition to this large library of the builtin functions, it provides you the flexibility of creating your own functions by writing their code, and then using them in your worksheets.

A User-Defined Function is created by you in a Visual Basic module, by combining mathematical expressions, built-in Excel functions, and Visual Basic code.

As an example of a user-defined function, we shall write a function that converts a value in Centigrade to Fahrenheit. The conversion rule for this is:

Fahrenheit value = 32 + (Centigrade value * 9 / 5)

The Visual Basic code for this function can be written as:

Function Ctof(InValue)

Ctof = 32 + (InValue * 9 / 5)

End Function

A user-defined function has the following parts:

•   The Function and End Function statements. These Visual Basic keywords mark the beginning and end of a function.

•   A name. This is the unique identifier of the function. The name is given immediately after the keyword Function. In the above example, the function name is Ctof.

•   Arguments. These are the values you supply to your function. Your function performs its calculations based on the value supplied by you. The list of arguments is given after the function name in parentheses, separating each argument from the others with a comma.

•   Visual Basic code and expressions. These are the instructions that tell your function which calculations to perform, or what actions to take. An expression is a combination of numbers, variables, and mathematical operators that yields a value.

•   The Return value. This is the value that your user-defined function returns after performing its calculations. The way to specify the return value is to write the function name, followed by the equal sign (=), followed by an expression.

 Recorded Macros User-Defined Functions Perform an action, such as formatting a cell or creating a chart. Return a value; cannot perform actions. Can be recorded. Must be created in a Visual Basic module. Are enclosed by the keywords Sub and End Sub. Are enclosed by the keywords Function and End Function.

A User-defined function is written in a Visual Basic module, and not in a worksheet where you do your usual work. You can have multiple Visual Basic module sheets in your workbook, just as you can have multiple worksheets in it. You can enter the code of your user-defined function in a new Visual Basic module, or, if you have already opened one or more Visual Basic modules, in any one of them.

•   To create a new Visual Basic module, choose Insert from the menu bar, then choose Macro, Module.

•   To switch to an existing Visual Basic module in the active workbook, select the tab of the Visual Basic module.

1.   Create a new Visual Basic module, or switch to an existing Visual Basic module where you want to store the code of your user-defined function.

2.   Type the code of your function. For example, you may type the code of the function Ctof illustrated earlier.

In the cell in which you want to use your user-defined function, type an equal sign (=), followed by the name of the function and the list of arguments within parenthesis, each argument separated from the other with a comma. For example, to use the Ctof function, enter the following in a cell:

=Ctof(100)

or

=Ctof(A1)

You can also use the Function Wizard button in the toolbars to search for a list of the user-defined functions available. When you press the Function Wizard button, a dialog box appears, which shows a list of function categories, and the functions in each category. Choose the “User Defined” category, and you will locate the name of your function in the list of functions on the right hand side.

Function Wizard button

You can assign a user-defined function to a function category, and also make the function wizard dialog boxes more user-friendly. For this purpose, follow the steps given below:

1.   Switch to the Visual Basic module in your workbook that contains the userdefined function.

2.   From the menu bar, choose View, Object Browser.

3.   In the Libraries/Workbooks box, type or select the name of the workbook containing your module.

4.   In the Objects/Modules box, select the module containing your function.

5.   In the Methods/Properties box, select the name of your function.

6.   Choose the Options button.

7.   In the Macro Options dialog box that appears, type a description for your function in the Description box.

8.   In the Function Category box, select the name of a category.

9.   Choose the OK button.

10.  In the Object Browse dialog box that reappears, choose the Show button.

Now, if you choose the Function Wizard button to select your user-defined function, it will appear like a normal built-in function in its dialog boxes.

You can use the IF THEN structure to execute one or more statements depending on some condition. For example:

If InValue >= 21 Then

End If

If InValue < 21 Then

End If

End Function

The IF THEN ELSE structure allows you to specify alternative blocks of statements, one of which is always run. For example:

If InValue >= 21 Then

Else

End If

End Function

You can also specify multiple alternative paths depending on the value of an expression with the IF THEN ELSEIF ELSE structure. For example:

Function ProfessionalTax(InValue)

If InValue < 2000 Then

ProfessionalTax = 0

ElseIf InValue < 4000 Then

ProfessionalTax = 20

Else         ProfessionalTax = 40

End If

End Function

The      SELECT          CASE structure           provides           an         alternative        way      to         the IF THEN ELSEIF ELSE structure, provided each ELSEIF statement evaluates the same expression. It can be written as follows:

Function ProfTax(InValue)

Select Case InValue

Case Is < 2000

ProfTax = 0

Case Is < 4000

ProfTax = 20

Case Else

ProfTax = 40

End Select

End Function

The standard Visual Basic term for both a recorded macro and a user-defined function is “procedure”.

A procedure is a block of Visual Basic code that is entered in a Visual Basic module, and is executed as a unit. It is a sequence of Visual Basic statements that does one task as per your requirements. There are two types of procedures: Sub procedures and Function procedures.

A Sub procedure performs an action, but does not return a value. It is enclosed by the Suband End Sub statements. A Sub procedure can be either recorded, or written by you in a Visual Basic module, or can be partly recorded and partly edited within a Visual Basic module.

A Function procedure returns a value, but cannot perform an action that changes the Microsoft Excel environment. It is enclosed by the Function and End Function statements. A function procedure cannot be recorded; it has to be written in a Visual basic module.

You can use the InputBox function to ask the user for a value. This function displays a dialog box that asks the user to enter a value. For example, the following code can be used to accept the user’s name:

YourName = InputBox("Enter your name", "User name")

The above code displays a dialog box as follows:

You can display a message on the user screen, with the MsgBox function. After reading the message, the user chooses a button to close the dialog box. For example:

MsgBox ("Thank you for trying this procedure.")

The above code displays the following box:

You can use the ampersand (&) operator to join two values of same or different kind. For example:

MsgBox ("Welcome, " & YourName)

Cells(2, TheQuarter + 1).Value = "Q" & TheQuarter

You can use the FOR NEXT loops to execute certain statements a specific number of times. In this loop, a counter variable is used to count the number of executions. For example, the following procedure sounds a tone the number of times you specify.

Sub ManyBeeps()

NumBeeps = InputBox("How many beeps?")

For Counter = 1 To NumBeeps

Beep

Next Counter

End Sub

In a Visual Basic module, you can refer to a cell with the Cells function (actually it is a method of the Range object). A cell is referred to with the following syntax:

Cells (RowNumber, ColumnNumber)

For example, the cell A4 is identified as:

Cells (1, 4)

You can use the Value property of a cell to assign a value to a cell. For example:

Cells(1, 1).Value = "Sales Analysis"

The above can also be written as:

Range("A1").Value = "Sales Analysis"

The following code prepares a matrix for sales analysis, using multiple calls to the Value property:

Sub cell1()

Cells(1, 1).Value = "Sales Analysis"

For TheYear = 1 To 6

Cells(TheYear + 2, 1).Value = 1990 + TheYear

Next TheYear

For TheQuarter = 1 To 4

Cells(2, TheQuarter + 1).Value = "Q" &

TheQuarter

Next TheQuarter

Cells(2, 6).Value = "Total"

End Sub

You can use the Formula property to assign a formula to a cell. For example:

Cells(3, 6).Formula = "=Sum(B2:B5)"

You can use the Activate method to make a specified cell active. For example:

Cells(3, 2).Activate

In Visual Basic, you work with objects, which have associated properties and methods. You can manipulate objects in procedures by using their properties or methods.

An object is something that you control with Visual Basic. For example, a range is an object, which you can format. Similarly, a worksheet is an object which you can use to calculate and display information.

Each object has characteristics that make that object useful to you. These characteristics are called properties. For example, a cell has a “value” property, which can be used to assign a value to a cell.

In addition to properties, objects also have methods, which are actions that objects can do. For example, a cell has an “activate” method, which makes that cell active.

Although you may expect a cell on a worksheet to be an object, cells are actually not called objects in Microsoft Excel. Instead, we treat the cell as a range, and use it as a Range object. Thus, to manipulate a single cell, we use a Range object that contains that one cell.

You can set the value of a property when you want to change the appearance or behaviour of an object. To set the value of a property, use the following syntax:

object.property = expression

For example:

Cells(1, 1).Value = "Sales Analysis"

You can examine the value of a property when you want to determine the condition of an object before your procedure performs additional actions. For example, you may check the value of a cell to determine whether some code should be executed.

If Cells(11, 1).Value < 0 Then

Cells(11, 1).Value = 0

End If

Certain properties of objects are “Read-only”, which means that such properties cannot be set by you. For example, the Column property of a Range object, which returns the number of the first column of a range, is a read-only property. You can use this property to determine the number of the first column in a range object, but you cannot set its value.

Cells(11, 1).Value = Cells(11, 5).Column

Sets or returns the width of the column which includes the specified cell. For example:

Cells(11, 5).ColumnWidth = 20

The ActiveCell property returns a Range object, which refers to the active cell in the active worksheet window. This property is used in conjunction with other range properties to set or examine the values for the active cell. For example:

ActiveCell.ColumnWidth = 5

Use the Font property to change the font of a cell. The font property itself returns a Font object, which has its own group of properties, which can be used to set or examine different aspects of the font of a cell. For example:

ActiveCell.Value = "Pragati Software Pvt. Ltd."

= "Courier New"

= 24      = True

You can use the With statement to refer to the same object for assigning multiple properties. For example:

With

.Name = "Courier New"

.Size = 24

.Bold = True

End With

Use the HorizontalAlignment property on a cell to set or examine its horizontal alignment. For example, the following code centers the text within the active cell:

ActiveCell.HorizontalAlignment = xlCenter

The value of this property can be any one of the following:

xlCenter           for centering within the cell      xlLeft  for left alignment         xlRight                         for right alignment       xlJustify for justification

Use the “Clear” method to clear the contents of a cell. For example:

ActiveCell.Clear     Cells(1, 1).Clear

You can use the Copy method of a range object to copy the contents of a cell to another cell. The syntax of this method is as follows:  object.Copy (destination)

For example, to copy the contents of cell F3 to the cell F4, you would write the code as follows:

Cells(3, 6).Copy (Cells(4, 6))

A Range Object refers to a range in a Microsoft Excel worksheet. There is no specific “cell” object in Excel. If you want to work on a cell, you use a range object which consists of the single cell.

There are various ways in which a range can be referred to in Visual Basic. One simple way is to use the “Range” method, such as:

Range("A1:B5")

Thus, you can assign the value “Test” to all cells in the range A1:B5 with the following code:

Range("A1:B5").Value = "Test"

Another common way of referring to a range is by using the “Cells” object to refer to the extremes of the desired range, such as:

Range(Cells(1, 1), Cells(5, 2)).Value = "Pragati"

The “Sort” method of a range object can be used to sort a specified range. For example, to sort the range A2:E16 on column A, the following code can be used:

Range("A2:E16").Sort key1:=Range("A1")

The detailed syntax of this method is:

RangeObject.Sort _

 key1 := key1, order1 := order1, key2 := key2, order2 := order2, _ _ key3 := key3, order3 := order3, header := header, matchcase := YesNo, where, orientation := orientation key1 is the first sort key. Required. order1 is the sort order for the first sort key. Optional. If this is xlAscending or omitted, sorting is done in ascending order. If this is xlDescending, sorting is done in descending order. key2 is the second sort key. Optional. order2 is the sort order for the second sort key. Optional. key3 is the third sort key. Optional. order3 is the sort order for the third sort key. Optional. header specifies whether the first row is a header row. Optional. If this is xlYes, the first row is considered a header row, and is not sorted. If this

is xlNo or omitted, no headers exist and the entire range is sorted. If xlGuess, Microsoft Excel guesses if and where there is a header.

matchcase specifies whether sorting is case sensitive. Optional. If True, sorting is case sensitive. If False, sorting is not case sensitive.

orientation determines whether sorting is done by rows, or by columns. Optional. If this is xlTopToBottom, or is omitted, rows are sorted. If this is xlLeftToRight, columns are sorted.

Sometimes, you will not know the size of a desired range at the time of writing the Visual Basic code, and yet you want to use the range object for some methods or properties. For example, you may build a list of employees in a worksheet, and the number of rows (employees) may be variable. You may want to write a code to sort the range of employees, without knowing the size of this range.

In such a situation, the “CurrentRegion” method of a range object can be used. Starting with a single cell, this method marks the entire area of adjoining rows and columns which is completely from the other cells by blank rows and blank columns.

For example:

You can also give a name to a range object within your Visual Basic code, so that you can subsequently refer to the same range, without using the “CurrentRegion” method repeatedly:

Set MyRange = Cells(1, 1).CurrentRegion

= "Times New Roman"

In the above code, MyRange is a variable which stores a range object. This variable is then be used in the subsequent commands to use the “Sort” method and the “Font” property on the range object.

You can select a range by using the “Select” method on a range. For example:

Range("A1:E5").Select or

Range("A3").CurrentRegion.Select

Once a range has been selected by this method, you can refer to that range by using the “Selection” property, such as:

= "Times New Roman"

You can use the “Columns” method on a range object, to refer to a specific column within a range. This method returns a range object, so you can use it for any purposes where a range object can be used.

For example, to refer to the first column within the current selection, you can use the following code:

Selection.Columns(1)

You can assign a name to the new range, as follows:

Set ListofEmployees = Selection.Columns(1)

and then,

= "Times New Roman"

The “Find” method can be used to search for a value within a range object. It returns a range object which refers to the first cell where the value is found. For example, to search for a value “EDP” within a columnar range, you would write the statement as follows:

set NewCell = Range("C3:C20").Find(what:="EDP")

Another example:

Sub range5()

Set                     FirstCell                     =

Range("A3").CurrentRegion.Columns(2).Find(what:="EDP")

FirstCell.Activate

End Sub

You can then search for the next occurrence of the previous search, by using the “FindNext” method. For example:

set NewCell = Range("C3:C20").FindNext

You can use the “Offset” method to refer to a cell (or a range) which is a certain distance away from another cell (or a range). In this method you specify the number of rows and the number of columns away from the current one. Its format is:

RangeObject.Offset(RowOffset, ColumnOffset)

where RowOffset is the number of rows away from the RangeObject. A positive value means a row down, while a negative value means a row above. Similarly, ColumnOffset is the number of columns away from the RangeObject.

In the following code example, NewCell refers to a cell below the current selection.

NewCell = Selection.Offset(1, 0)

The FOR EACH NEXT statement allows you to process each cell within a range. In its simple form, its syntax is:

FOR EACH element IN group

[statements]

NEXT

where,

element          is any variable name used to go through the entire range,

group             is a reference to the range,

statements refers to one or more statements that are executed on each cell within the range.

Excel Visual Basic has a Worksheets object, which is a collection of all the worksheets in the active workbook. You refer to a specific worksheet, by using this object followed by the name of the worksheet in parenthesis. For example, sheet “Sheet1” is referred to as:

Worksheets("Sheet1")

Thus, to assign a name to this sheet, we could write:

Sub worksheet1()

Worksheets("Sheet1").Name = "Sheet One"

End Sub

The active worksheet is referred to as “ActiveSheet”. Thus:

Sub worksheet2() ActiveSheet.StandardWidth = 12

End Sub

You can use the “Next” property to refer to the next worksheet in a workbook. Similarly, the “Previous” property can be used to refer to the previous worksheet available.

Thus, the following code can be used to activate the next worksheet:

Sub worksheet3()

.Activate

End Sub

The “Add” method on a worksheets object is used for adding a new worksheet to the workbook. The new worksheet becomes the active worksheet. Its format is:

where,

 before specifies the sheet before which the new sheet is added. Optional. Default is the active sheet. after specifies the sheet after which the new sheet is added. Optional. count specifies the number of sheets to be added. Optional. Default is 1. type specifies the type of sheet to be added. Optional. Not recommended. Provided for backward compatibility.

For example:

Sub worksheet4()     before:=Worksheets("Sheet One") End Sub

The “Delete” method can be used for removing a worksheet from the workbook. For example:

Worksheets("Sheet16").Delete

You can use the “PrintOut” method for printing a worksheet. Its syntax is:

object.PrintOut(from, to, copies, preview)

where,

 from is the starting page number for the printing. Optional. If omitted, printing starts from the beginning. to is the ending page number of the printing. Optional. If omitted, printing goes up to the last page. copies is the number of copies to print. Optional. Default is one. preview determines whether print preview is invoked before the printing. If False or omitted, the worksheet is printed immediately. If True, Excel invokes print preview before printing.

For example:

ActiveSheet.PrintOut

If you just want to have a print preview of the worksheet, you can use the “PrintPreview” method, as follows:

ActiveSheet.PrintPreview

To select a worksheet, use the “Select” method, such as:

ActiveSheet.Select

or

Worksheets (“Sheet One”).Select

Excel Visual Basic has a Workbooks object, which is a collection of all the workbooks that are open at a time. You can refer to a specific worksheet, by using this object followed by the name of the workbook in parenthesis. For example, the workbook , if opened, is referred to as:

Workbooks("")

Thus, we can write the following code to activate the workbook “”:

Sub workbook1()

Workbooks("").Activate

End Sub

You can use the “Open” method to open a workbook. For example:

filename:="g:\usr\natwest\"

If the workbook being opened has any Auto_Open macro, it will not be run, when you open the file with Visual Basic macro. If you want to run the Auto_Open macro, you need to use the “RunAutoMacros” method, as follows:

The following example runs the Auto_Open macro for a workbook being opened:

filename:="g:\usr\natwest\"   ActiveWorkbook.RunAutoMacros xlAutoOpen

The “Close” method is used for closing a workbook. For example:

ActiveWorkbook.Close

Some of the important additional arguments are as follows:

saveChanges Optional. If there are no changes to the workbook in the window, this argument is ignored. If there are changes to the workbook, and there are other windows open on the workbook, this argument is ignored. If there are changes to the workbook, and there are no other windows open on the workbook, this argument takes the following action:

Value             Action

True Saves the changes to the workbook. If there is not yet a filename associated with the workbook, then fileName is used. If fileName is omitted, the user is asked to supply a filename.

False              Does not save the changes to this file.

Omitted Displays a dialog box asking the user whether or not to save changes.

fileName                    Optional. Save changes under this filename.

Closing a workbook from Visual Basic does not run the Auto_Close macro in the workbook. Use the RunAutoMacros method to run the auto close macros. For example:

Workbooks("").Activate

ActiveWorkbook.RunAutoMacros xlAutoClose

ActiveWorkbook.Close

To open a new (blank) workbook, use the “Add” method on the Workbooks object. For example:

Creating a chart consists of a number of steps. The first step is to create a ChartObjects object, which marks an area for the chart. This is done by using the “Add” method for the ChartObjects object.

For example:

24, 24, 300, 200

The arguments to the “Add” method are:

 left, top specify the initial coordinates of the new object, in points (1/72 inches) relative to the top left corner of the cell A1 on a worksheet, or to the upper left corner of a chart. width, height specify the initial size of the object, in points.

If you want the chart object to be selected also (helpful as you would probably do a lot of additional things on it), you can apply the “Select” method on the same, as follows:

(24,       24,       300,

200).Select

The “ChartWizard” method provides you with options to modify the properties of a chart. You can use this method to quickly format a chart without setting all the properties individually. It is a non-interactive method, unlike the Chart Wizard available in the Toolbars, and changes only the selected properties.

Its syntax is as follows:

object.ChartWizard(source, gallery, format, plotBy, categoryLabels, seriesLabels, _

hasLegend, title, categoryTitle, valueTitle, extraTitle)

 where, object is the Chart object. source specifies a range that contains the source data for the chart. Optional. If this argument is omitted, Microsoft Excel uses the current selection. gallery specifies the chart type (one of xlArea, xlBar, xlColumn, xlLine, xlPie, xlRadar, xlXYScatter, xlCombination, xl3DArea, xl3DBar, xl3DColumn, xl3DLine, xl3DPie, xl3DSurface, or xlDoughnut). Optional. format specifies the option number for the built-in autoformats. Optional. Can be a number from 1 to 10, depending on the gallery type. If this argument is omitted, Microsoft Excel chooses a default value based on the gallery type and data source. plotBy specifies whether the data for each series is in rows or columns (either xlRows or xlColumns). Optional. categoryLabels an integer specifying the number of rows or columns within the source range containing category labels. Optional. Legal values are from zero to one less than the maximum number of the corresponding categories or series. seriesLabels an integer specifying the number of rows or columns within the source range containing series labels. Optional. Legal values are from zero to one less than the maximum number of the corresponding categories or series. hasLegend true to include a legend. Optional. title chart title text. Optional. categoryTitle category (x) axis title text. Optional. valueTitle value axis title text. Optional. extraTitle series axis title for 3-D charts, second value axis title for 2-D charts. Optional.

For example:

ActiveChart.ChartWizard   Source:=Range(GraphRange), Gallery:= _

xlCombination, Format:=3, PlotBy:=xlColumns,

CategoryLabels:=1 _

, SeriesLabels:=1, HasLegend:=1, Title:=cComp, CategoryTitle _

:="Dates",                    ValueTitle:="Price",

ExtraTitle:="Pr\Dis"

A workbook that has been set up to allow multiple users on a network to view and make changes at the same time. Each user who saves the workbook sees the changes made by other users. You must have Microsoft Excel 97or later to modify a shared workbook.Share a workbook   If you want several users to work in the same workbook simultaneously, you can save the workbook as a shared workbook. Users can then enter data, insert rows and columns, add and change formulas, and change formatting.

1.   On the Tools menu, click Share Workbook, and then click the Editing tab.

2.   Select the Allow changes by more than one user at the same time check box, and then click OK.

When prompted, save the workbook.

On the File menu, click Save As, and then save the shared workbook on a network location where other users can gain access to it.

Notes

If you copy the shared workbook to a network location, make sure any links to other workbooks or documents are intact. Use the Links command on the Edit menu to make corrections to the link definitions.

This procedure also turns on the change history, which allows you to view information about changes to the shared workbook and about conflicting changes that are kept or discarded. When you maintain the change history, you can also make copies of the shared workbook that you can merge together after they have been changed.

To make changes to a shared workbook created in Microsoft Excel 97 or later, you must use Microsoft Excel 97 or later. You cannot use earlier versions of Excel.

All users who have access to the network location where a shared workbook is stored have the same access to the shared workbook. If you want to prevent certain types of access to a shared workbook, you can protect the shared workbook and the change history.

If you want to merge multiple copies of a workbook, you must share the workbook before distributing it to your reviewers.

Each user of a shared workbook can set independent options for how often to receive other users' changes.

1.   Open the shared workbook.

2.   On the Tools menu, click Share Workbook, and then click the Advanced tab.

To see other users' changes each time you save the shared workbook, click When file is saved under Update changes.

To view other users' changes periodically, click Automatically every under Update changes, type how often you want to get updates in the Minutes box, and then click Just see other users' changes. To save the shared workbook each time you get an update so that other users can see your changes, click Save my changes and see others' changes.

Save the shared workbook.

Each user of a shared workbook can set independent view and print options. Open the shared workbook.

On the Tools menu, click Share Workbook, and then click the Advanced tab.

To save your personal print settings, make sure the Print settings check box is selected under Include in personal view. Print settings include page breaks, print areas, settings you make in page break preview (View menu, Page Break Preview command), and settings you make in the Page Setup dialog box (File menu).

To save any settings you make by using the commands on the Filter submenu of the Data menu, including filtering done using the AutoFilter command, make sure the Filter settings check box is selected under Include in personal view.

Save the shared workbook.

Note   Microsoft Excel automatically saves the location of the currently displayed worksheet as well as your personal settings for the options in the Zoom dialog box (View menu), in the Zoom box on the Standard toolbar, and on the View tab of the Options dialog box (Tools menu).

Some features of Microsoft Excel are not available when you use a shared workbook. If you need to use these features, do so before you share the workbook, or remove the workbook from shared use.

In a shared workbook, you cannot do the following:

Cells

Merge cells. You can view cells that were merged before you shared the workbook. Insert or delete blocks of cells. You can insert or delete entire rows and columns.

Worksheets, dialog boxes, and menus Delete worksheets.

Make changes to dialog boxes or menus.

Conditional formats and data validation

Define or apply conditional formats. However, you can see the effects of conditional formats applied before you shared the workbook.

Set up or change data validation restrictions and messages. However, you can see the effects of restrictions and messages that were set up before you shared the workbook.

Insert or change charts, pictures, objects, or hyperlinks.

Use the drawing tools.

Assign a password to protect individual worksheets or the entire workbook. Protection that you applied before sharing the workbook remains in effect after you share the workbook.

Passwords that you assigned before sharing the workbook remain in effect after you share the workbook.

Scenarios

Save, view, or make changes to scenarios.

Outlines, groups, and subtotals

Group or outline data.

Insert automatic subtotals.

Data tables and PivotTables Create data tables.

Create PivotTables or change the layout of existing PivotTables.

Macros

Write, change, view, record, or assign macros. However, you can record operations in a shared workbook into a macro stored in another workbook that isn't shared. In a shared workbook, you can run macros that were created before you shared the workbook; although if you run a macro that includes an unavailable operation, the macro stops running when it reaches the unavailable operation.

If the workbook you want to protect is already shared, and you want to assign a password to protect the sharing or you want to protect other worksheet or workbook features, remove the workbook from shared use.

If you want to require that users supply a password to open the shared workbook, set this password.

If you want to require that users supply a password when they make changes and save the shared workbook, set this password.

If you don't want other users to see certain rows or columns on a worksheet, select the rows or columns. On the Format menu, point to Row or Column, and then click Hide.

If you want to allow others to change only specific areas of the shared workbook, unlock the areas, and then protect the worksheets. (This action also prevents others from seeing hidden rows or columns.)

If you don't want others to see specific worksheets in the shared workbook, click a worksheet, point to Sheet on the Format menu, and then click Hide. Repeat for each worksheet that you want to hide.

After you hide the worksheets, you must protect the workbook to keep other users from redisplaying the hidden worksheets. On the Tools menu, point to Protection, and then click Protect Workbook. Select the Structure check box, and then click OK.  If you want to change the number of days that Microsoft Excel will maintain the change history for the shared workbook (the default is 30 days), click Share Workbook on the Tools menu, and then click the Editing tab. Select the Allow changes by more than one user at the same time check box, and then click the Advanced tab. Under Track changes, make sure Keep change history for is selected, and then type the number of days you want to maintain the change history in the Days box. Click the Editing tab, clear the Allow changes by more than one user at the same time check box, and then click OK.

On the Tools menu, point to Protection, and then click Protect Shared Workbook or Protect and Share Workbook.

Select the Sharing with track changes check box.

If you want to require other users to supply a password to turn off the change history or remove the workbook from shared use, type the password in the Password box, and then reenter the password when prompted.

When prompted, save the workbook. This shares the workbook and turns on the change history.

When you protect sharing for a workbook, users cannot remove the workbook from shared use or turn off the change history.

In a workbook that is already shared, you can turn on protection for sharing and the change history, but you cannot assign a password for this protection. To assign a password, you must first remove the workbook from shared use.

When a user closes a shared workbook, Microsoft Excel disconnects the user from the shared workbook. Use this procedure to remove a user who appears to be connected to a shared workbook but is no longer working in the workbook or whose network connection is broken.

Caution   When you remove a user who is currently working in a shared workbook, the user's unsaved work will be lost.

On the Tools menu, click Share Workbook, and then click the Editing tab. In the Who has this workbook open now box, click the name of the user you want to disconnect, and then click Remove User.

Tip If a user no longer needs to work with a shared workbook, you can reduce the size of the workbook file by deleting the user's personal view settings. On the View menu, click Custom Views. In the Views box, click the user's view, and then click Delete

If you decide that you no longer want others to make changes to a shared workbook, you can open and work in the workbook as its only user. When you remove a workbook from shared use, you disconnect all other users from the shared workbook, turn off the change history, and erase the stored change history so that you can no longer view the history or merge this copy with other copies of the shared workbook.

Caution: To ensure that others do not lose work in progress, make sure that all other users have been notified so that they can save and close the shared workbook before you remove it from shared use.

On the Tools menu, click Share Workbook, and then click the Editing tab.

Make sure that you are the only person listed in the Who has this workbook open now box. If other users are listed, they will lose any unsaved work.

Clear the Allow changes by more than one user at the same time check box, and click OK.

When prompted about the effects on other users, click Yes.

When users of a shared workbook make changes that conflict, such as typing different values in the same cell and then saving the workbook, Microsoft Excel provides several tools to help manage the conflicting changes.

Decide which changes to keep   When you save a shared workbook, you can review conflicting changes and decide which changes to keep, or you can automatically save your own changes instead of any changes that conflict with yours. Each user of a shared workbook can set this option independently.

Reviewing each change   If you decide to review the conflicting changes, you can view information about each change and decide whether to keep or discard each change.

View information from past editing sessions If you maintain the change history for a shared workbook, you can view information from past editing sessions about changes that were kept, replaced, or discarded, including the author and the data that was entered and later replaced.

Each user of a shared workbook can set independent review options.

1.  Open the shared workbook.

2.  On the Tools menu, click Share Workbook, and then click Advanced. To review each conflicting change and decide which changes to keep when you save the workbook, click Ask me which changes win under Conflicting changes between users.

To replace any conflicting changes with your own changes each time you save, click The changes being saved win.

Save the workbook.

If you don't want to see the Resolve Conflicts dialog box when you save a shared workbook, click The changes being saved win

Use this procedure when you save a shared workbook and see the Resolve Conflicts dialog box.

To keep your change, click Accept Mine.

To keep the other person's change, click Accept Other.

Repeat steps 1 and 2 for each change.

To keep all of your remaining changes, click Accept All Mine.

To keep all of the other users' remaining changes, click Accept All Others.  You can save a copy of the workbook with all your changes by clicking Cancel, clicking Save As on the File menu, and then typing a new name for the file.

Note   If you don't want Microsoft Excel to display the Resolve Conflicts dialog box when you save a shared workbook, you can set an option to save your changes automatically instead of reviewing conflicting changes.

When you create a shared workbook, the change history is turned on so that you can view information about previous conflicting changes. If you turn off the change history, Microsoft Excel does not preserve information about conflicting changes.

On the Tools menu, point to Track Changes, and then click Highlight Changes.  Select the When check box, and then click All in the When box.

Make sure the Who and Where check boxes are cleared.

Select the List changes on a new sheet check box, and then click OK.

When the History worksheet appears, scroll it to the right if necessary to view the Action Type and Losing Action columns.

Conflicting changes that were kept display "Won" in the Action Type column.  In the Losing Action column, row numbers appear for those lines in the History worksheet that describe discarded changes.

Note   The List changes on a new sheet check box becomes available only after the shared workbook has been saved.

When you keep the change history for a workbook, Microsoft Excel also turns on workbook sharing. Some Microsoft Excel commands and operations are not available in a shared workbook.

1.  On the Tools menu, click Share Workbook, and then click the Editing tab.

2.  Select the Allow changes by more than one user at the same time check box.

4.  Under Track changes, click Keep change history for, and then type the number of days you want to maintain the change history in the Days box.

Be sure to enter a large-enough number of days because Excel incrementally erases the change history permanently after the number of days elapses.

Click OK, and when prompted to save the file, click OK.

The change history includes information about how users resolved conflicting changes to the workbook, including the data from changes that were discarded. Each time you close the workbook, Microsoft Excel erases any part of the stored change history that is older than the number of days you specified. The actual changes are retained. Microsoft Excel does not turn on change highlighting when you turn on the change history.

On the Tools menu, point to Track Changes, and then click Accept or Reject Changes.

If prompted to save the workbook, click OK.

Select the changes to review.

To review changes made by another user, select the Who check box, and then click the user in the Who box.

To review changes by all users, clear the Who check box.

To review changes to a specific area on a worksheet, select the Where check box, and then enter a reference to the area.

To review changes to the entire workbook, clear the Where check box.

Click OK, and then read the information about the first change in the Accept or Reject Changes dialog box. The information also describes any dependent changes that are affected by the action you take for this change. You may need to use the scroll arrows to see additional information.

To accept the change and clear its change highlighting, click Accept.

To undo the change on the worksheet, click Reject.

If prompted to select a value for a cell, click the value you want, and then click Accept.

Repeat steps 4 and 5 for each change, or click Accept All or Reject All to accept or reject all remaining changes. You must accept or reject a change before you can advance to the next change.

Note:   You can view information about rejected changes, including any data that was deleted. On the History worksheet, rejected changes display "Undo" or "Result of rejected action" in the Action Type column.

When you mark changes in a workbook by using the Highlight Changes command, you also turn on workbook sharing (if the workbook is not currently shared) and the change history.

Some Microsoft Excel commands and features are not available in a shared workbook.

On the Tools menu, point to Track Changes, and then click Highlight Changes.  Make sure the Track changes while editing check box is selected. This check box turns on workbook sharing and the change history.

Select the When check box, click Not yet reviewed in the When box, and then click OK.

If prompted, save the workbook.

Make the changes you want on the worksheet. Microsoft Excel marks cells that you change, insert, or delete with a highlight color.

Note : When highlighting changes, Microsoft Excel does not mark some changes, such as formatting.

If a workbook is shared and change tracking is protected with a password, users can make changes without tracking them only by removing the workbook from shared use. And to do this, users would have to supply the correct password. You can set the number of days to maintain the change history, and users cannot reduce the number of days or turn off the change history without supplying the password. If you don't change the setting, Microsoft Excel maintains the change history for the default time of 30 days or for the number of days specified the last time the workbook was shared. Make sure the change history will be turned on when you protect the workbook.

If the workbook is not currently shared, click Share Workbook on the Tools menu, and then click the Editing tab. Make sure the Allow changes by more than one user at the same time check box is selected, and then click the Advanced tab. Under Track changes, make sure Keep change history for is selected, and then type the number of days you want to maintain the change history in the Days box. Click the Editing tab, clear the Allow changes by more than one user at the same time check box, and then click OK.

If the workbook is currently shared, click Share Workbook on the Tools menu, and then click the advanced tab. Under Track changes, make sure Keep change history for is selected, and type the number of days you want to maintain the change history in the Days box. If you plan to assign a password in step 4, click the Editing tab, clear the Allow changes by more than one user at the same time check box. Click OK.

On the Tools menu, point to Protection, and then click Protect and Share Workbook.

Select the Sharing with track changes check box.

If you want others to supply a password to remove protection from the sharing and change history, type the password in the Password box, and then reenter the password when prompted. If the workbook is currently shared, you cannot assign a password. If prompted, save the workbook.

Note   When you again want to allow changes without tracking them, point to Protection on the Tools menu, and then click Unprotect Shared Workbook. If prompted, enter the password. When you remove password protection from the sharing, you also remove the workbook from shared use.

When you merge several copies of a shared workbook in which users have entered changes, Microsoft Excel requires that each copy of the shared workbook maintain the change history from the day when you create the copies through the day when you merge them. If the number of days you specified has been exceeded, you can no longer merge the copies. If you aren't sure how long the review process will take, make sure you maintain the change history for a sufficient number of days, or enter a large number of days, such as 1,000.

On the Tools menu, click Share Workbook, and then click the Editing tab.

Select the Allow changes by more than one user at the same time check box. Click the Advanced tab.

Under Track changes, click Keep change history for. In the Days box, type a number at least as long as the number of days you expect reviewers to spend making changes and comments in the shared workbook.

Click OK, and save the file.

To make copies of the workbook that you can distribute to reviewers, click Save As on the File menu. Give each copy a different name.

Note   To make sure reviewers don't turn off the change history, you can require that the change history be maintained before you make the copies and distribute them.

If you plan to merge copies of a shared workbook, you must turn on the change history for the shared workbook before you make the copies for distribution to reviewers and before anyone makes any changes to the copies. You also must complete the merge within the time period you specified to maintain the change history.

Open the copy of the shared workbook into which you want to merge changes from another workbook file on disk.

On the Tools menu, click Merge Workbooks.

If prompted, save the shared workbook.

In the Select Files to Merge into Current Workbook dialog box, click a copy of the shared workbook that has changes to be merged, and then click OK. Repeat steps 2 through 4 until all copies of the shared workbook are merged.

Note   If a cell contains a comment, the comment includes the name of the person who inserted the comment. When you merge shared workbooks and a cell has comments from more than one person, the comments appear one after another in the comment box for the cell.

Tip   If you want to merge several copies of a workbook in one step, you can select more than one workbook in the Select Files to Merge into Current Workbook dialog box by holding down CTRL or SHIFT and then clicking the file names.

1.  Click the cell to which you want to add the comment.

2.  On the Insert menu, click Comment.

3.  In the box, type the comment text.

4.  When you finish typing the text, click outside the comment box.

Instead of copying entire cells, you can copy specified contents from the cells — for example, you can copy the resulting value of a formula without copying the formula itself.

1.  Select the cells you want to copy.

2.  Click Copy

3.  Select the upper-left cell of the paste area.

4.  On the Edit menu, click Paste Special.

5.  Click an option under Paste, and then click OK.

Select the cells, rows, or columns you want to clear.

On the Edit menu, points to clear, and then click All, Contents, Formats, or Comments.

1.  Click the cell with the comment you want to edit.

2.  On the Insert menu, click Edit Comment.

On the Tools menu, click Options, and then click the View tab.

To hide comments, even when you rest the pointer over the cells that contain them, and also clear the comment indicators from the upper-right corners of the cells with comments, click None under Comments.

To display comments when you rest the pointer over cells that contain them, and also show the comment indicators, click Comment indicator only. To display both comments and indicators regardless of the mouse position, click Comments & indicator.

To display an individual comment, right-click the cell that contains the comment, and then click Show Comment on the shortcut menu.

1.  Click the worksheet.

2.  On the File menu, click Page Setup, and then click the Sheet tab.

3.  Do one of the following:

To print the comments at the end of the sheet, click At end of sheet in the Comments box.

To print the comments where they appear on the worksheet, click As displayed on sheet in the Comments box.

Microsoft Excel provides the following security and protection features:

You can limit changes to an entire workbook.

You can protect workbook sharing and the change history.

You can limit access to a workbook by requiring a password to open it or save it, or you can recommend that others open the workbook as read-only.

When you protect the worksheet, the cells and graphic objects that you did not unlock in steps 2 and 3 are protected and cannot be changed.

Switch to the worksheet you want to protect.

Unlock any cells that you want to be able to change after you protect the worksheet.  Unlock any graphic objects that you want to be able to change after you protect the worksheet.

Hide any formulas that you don't want to be visible.

On the Tools menu, point to Protection, and then click Protect Sheet.

To prevent changes to cells on worksheets or to data and other items in charts, and to prevent viewing of hidden rows, columns, and formulas, select the Contents check box.

To prevent changes to graphic objects on worksheets or charts, select the Objects check box.

To prevent changes to the definitions of scenarios on a worksheet, select the Scenarios check box.

To prevent others from removing worksheet protection, type a password, click OK, and then retype the password in the Confirm Password dialog box. Passwords are case sensitive. Type the password exactly as you want to enter it, including uppercase and lowercase letters.

If you assign a password, write it down and keep it in a secure place. If you lose the password, you cannot gain access to the protected elements on the worksheet.

On the Tools menu, point to Protection, and then click Protect Workbook.

To protect the structure of a workbook so that worksheets in the workbook can't be moved, deleted, hidden, unhidden, or renamed and new worksheets can't be inserted, select the Structure check box.

To use windows of the same size and position each time the workbook is opened, select the Windows check box.

To prevent others from removing workbook protection, type a password, click OK, and then retype the password in the Confirm Password dialog box. Passwords are case sensitive. Type the password exactly as you want to enter it, including uppercase and lowercase letters.

When you assign a password, write it down and keep it in a secure place. If you lose the password, you cannot gain access to the protected workbook elements.

Note :  If you add a password-protected workbook to a binder the password protection is lost. You will be prompted to enter the password when you add the workbook to the binder, but the protection is removed after it becomes a binder section.

When you protect the worksheet, the cells and graphic objects that you did not unlock in steps 2 and 3 are protected and cannot be changed.

Switch to the worksheet you want to protect.

Unlock any cells that you want to be able to change after you protect the worksheet.  Unlock any graphic objects that you want to be able to change after you protect the worksheet.

Hide any formulas that you don't want to be visible.

On the Tools menu, point to Protection, and then click Protect Sheet.

To prevent changes to cells on worksheets or to data and other items in charts, and to prevent viewing of hidden rows, columns, and formulas, select the Contents check box.

To prevent changes to graphic objects on worksheets or charts, select the Objects check box.

To prevent changes to the definitions of scenarios on a worksheet, select the Scenarios check box.

To prevent others from removing worksheet protection, type a password, click OK, and then retype the password in the Confirm Password dialog box. Passwords are case sensitive. Type the password exactly as you want to enter it, including uppercase and lowercase letters.

If you assign a password, write it down and keep it in a secure place. If you lose the password, you cannot gain access to the protected elements on the worksheet.

22