2: Formulas and Functions



Similar documents
Creating Basic Excel Formulas

Excel Level Two. Introduction. Contents. Exploring Formulas. Entering Formulas

The Center for Teaching, Learning, & Technology

ECDL. European Computer Driving Licence. Spreadsheet Software BCS ITQ Level 2. Syllabus Version 5.0

Excel 2007 Basic knowledge

Microsoft Excel 2010 Part 3: Advanced Excel

SOME EXCEL FORMULAS AND FUNCTIONS

Excel: Introduction to Formulas

ROUND(cell or formula, 2)

Formulas & Functions in Microsoft Excel

Performing Simple Calculations Using the Status Bar

Q&As: Microsoft Excel 2013: Chapter 2

Excel Project From the Start menu select New Office Document. If necessary, click the General tab and then double-click Blank workbook.

Commonly Used Excel Formulas

Formulas & Functions in Microsoft Excel

Intro to Excel spreadsheets

MICROSOFT EXCEL Formulas, Functions, & Macros. Documented by Vincent J. Yanusauskas Computer Training Coordinator

Basic Formulas in Excel. Why use cell names in formulas instead of actual numbers?

Microsoft Excel Tips & Tricks

Excel 2003 A Beginners Guide

Excel 2007: Basics Learning Guide

MS Excel. Handout: Level 2. elearning Department. Copyright 2016 CMS e-learning Department. All Rights Reserved. Page 1 of 11

Excel 2007 A Beginners Guide

A User Manual for Benefit Cost Analysis Using Microsoft Excel

What is Microsoft Excel?

SECTION 2: Working with Functions and Formulas

Introduction to Microsoft Excel 1 Part I

Commonly Used Excel Functions. Supplement to Excel for Budget Analysts

MICROSOFT EXCEL FORMULAS

ACADEMIC TECHNOLOGY SUPPORT

Microsoft Excel Basics

Getting Started with Excel Table of Contents

INTRODUCTION TO EXCEL

Formatting Formatting Tables

Excel Functions (fx) Click the Paste Function button. In the Function Category select All. Scroll down the Function Name list And select SUM.

MICROSOFT EXCEL STEP BY STEP GUIDE

How To Analyze Data In Excel 2003 With A Powerpoint 3.5

Microsoft Excel 2010 Tutorial

2015 County Auditors Institute. May Excel Workshop Tips. Working Smarter, Not Harder. by David Scott,

How To Use Excel On A Computer Or A Computer With A Cell Phone Or Cell Phone

To launch the Microsoft Excel program, locate the Microsoft Excel icon, and double click.

Excel 2010 Level 2. Computer Training Centre, UCC, /3751/3752

Introduction to Microsoft Excel 2010

Microsoft Excel 2007 Consolidate Data & Analyze with Pivot Table Windows XP

Excel 2003 Tutorial I

Excel basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Basic Excel Handbook

Years after US Student to Teacher Ratio

Excel. Microsoft Office s spreadsheet application can be used to track. and analyze numerical data for display on screen or in printed

Introduction to Excel

Microsoft Excel - XP Intermediate

Excel Intermediate. Table of Contents UPPER, LOWER, PROPER AND TRIM...28

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Creating Charts in Microsoft Excel A supplement to Chapter 5 of Quantitative Approaches in Business Studies

0 Introduction to Data Analysis Using an Excel Spreadsheet

PA Payroll Exercise for Intermediate Excel

ACS Microcomputer Workshop Excel: Functions and Data Analysis Tools

Preface of Excel Guide

Excel 2010 Formulas & Functions

Excel 2010: Create your first spreadsheet

Commission Formula. Value If True Parameter Value If False Parameter. Logical Test Parameter

Essential Skills for Spreadsheets Microsoft Excel TR Leger Adult Literacy and Employment Preparation Program

Probability Distributions

How To Use Excel To Compute Compound Interest

SECTION 2-1: OVERVIEW SECTION 2-2: FREQUENCY DISTRIBUTIONS

Introduction to Microsoft Excel 2007/2010

ITS Training Class Charts and PivotTables Using Excel 2007

Using Microsoft Excel 2010

Advanced Microsoft Excel 2013

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Excel Basics for Account Reconciliation

Using Basic Financial and Logical Functions

How To Use Excel With A Calculator

MBA Quantitative Methods PC-Exercises Introductory Examples

Computer Training Centre University College Cork. Excel 2013 Level 1

Microsoft Excel Introduction to Microsoft Excel 2007

Table of Contents TASK 1: DATA ANALYSIS TOOLPAK... 2 TASK 2: HISTOGRAMS... 5 TASK 3: ENTER MIDPOINT FORMULAS... 11

Using Formulas, Functions, and Data Analysis Tools Excel 2010 Tutorial

How to Use Excel 2007

Microsoft Access 3: Understanding and Creating Queries

Excel -- Creating Charts

MODELLING. IF...THEN Function EXCEL Wherever you see this symbol, make sure you remember to save your work!

Creating A Grade Sheet With Microsoft Excel

Formulas, Functions and Charts

Excel Formulas & Graphs

Graphing Parabolas With Microsoft Excel

Microsoft Excel 2013 Tutorial

Introduction to MS EXCEL 2007 Data entry & formatting Using formulas & functions Presenting data with charts Database features in Excel

MICROSOFT WORD TUTORIAL

Using Pivot Tables in Microsoft Excel 2003

Using VLOOKUP to Combine Data in Microsoft Excel

EXCEL PIVOT TABLE David Geffen School of Medicine, UCLA Dean s Office Oct 2002

Microsoft Excel: Formulas, Formulas...

Below is a very brief tutorial on the basic capabilities of Excel. Refer to the Excel help files for more information.

Basic Microsoft Excel 2007

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

CSC102B Excel TUTORIAL

How To Understand And Understand A Function In Excel 3.5

EXCEL SPREADSHEET MANUAL

Advanced Excel Charts : Tables : Pivots : Macros

Transcription:

2: Formulas and Functions Simple Formulas 1 Arithmetic Operators 1 Copying formulas 2 Cell References: Relative and Absolute Worksheet Functions 4 The AutoSum Tool The Paste Function and Formula Palette Tools Editing a Formula 7 Some Common Functions 8 Getting Help with Worksheet Functions 9 Nesting Formulas 9 The IF function 10 Array Functions 12 Error values 12 Giving Names to Cells 1 The Danger of Range Labels 1 Simple Formulas Formulas begin with an equal symbol (=). For quick calculations, or to enter constant values, we may use formulas such as =72/6 or =(4+12)/7. But we more frequently use formulas that contain cell references. For example, =B2/B or =(C4+C)/7. A cell containing a formula will display a value. The formula may be viewed in the Formula Bar, or by editing the cell. You may type a formula using lowercase letters for the cell references; Microsoft Excel will make them uppercase when you complete the entry. Furthermore, you may add spacing to make the formula more readable. For example, we may use =(C4 + C) / 7. The use of parentheses is discussed below. Arithmetic Operators We need to know the symbols used to make a formula and their order of precedence. All computer applications use the asterisk ( ) for multiplication and the forward slash (/) for division. So the arithmetic operation 4 12 would be entered as =4 12 /. If asked to evaluate + 2 most of us would offer 1 as the answer rather than 16 because we would perform the multiplication before the addition. We would give multiplication a higher precedence than addition. When we need to override this order of precedence, we use parentheses. In this example, we would write ( + ) 2 and in Excel we would enter the formula =( + ) 2. In Excel, the arithmetic operators in order of precedence are: negation exponentiation multiplication & division addition & subtraction ^ * / + Below we see some examples of how arithmetic expressions (top row of table below) are translated into Excel formulas (middle row). Generally, Excel formulas contain cell addresses. The bottom row gives examples.

2 Formulas and Functions 0( 1 + 0. 04) 4+ 8 4+ 7 121 =0*(1 + 0.04)^ =(4+)/ 8 =(4+)/(*7) =121^(1/) =A1*(1+A2)^ =(B1 + B2)/2-8 =(D1 + D2)/(D - D4) =F1^(1/) In these examples all the parentheses are required. In other cases, we may use additional, non essential, parentheses to make the formula easier to understand. For example, we might code =(B1*12%) + (B2*1%). Note that Excel considers % an operator so strictly speaking it should be in the table above between negation and exponentiation but it is doubtful if you will ever need to know this esoteric piece of information. Quantitative Approaches in Business Studies Chapter 2 Exercise 1: This exercise has problems requiring you to evaluate expressions such as (a)!6 + 7! 2 and (b) 4 8 +. We can solve these in Excel (but please do learn how to do them with your calculator also) using one of two ways. Figure 1 shows the straightforward way for solving type (a) problems. The mathematical expression for each problem is entered in a single cell and Excel displays the result. In Figure 2, three cells are used for the values while a fourth is used for a formula. If we rewrite!6 + 7! 2 as +(!6) + (7) +(!2) we can see that the formula needed is one that sums the three values: =A1+A2+A. This approach lets us solve a series of similar problems; just replace the values in A1:A and A4 will give the correct result. Figure 1 Figure 2 Problems of the type in Exercise 2 may be solved in similar ways. Thus to compute the 1 1 value of + in one cell, enter the formula=(1/4)-(/8)+(½). Are the parentheses 4 8 2 necessary? No, but they make it easier to see what you are doing. You should now be able to solve the problems in Exercise using many cells or a single cell. Copying formulas In the worksheet below we calculate the cost of fruits and vegetables for a Boy Scout

Formulas and Functions camp. Begin by entering the text values in column A and row 1. To align the column headings to the right select B1:D1 and click on the right align tool. Enter the values in B2:C6 and format the B2:B6 to show two decimal places. The formula in D2 is =B2 C2. Of course, this may be entered by simply typing it, but you may wish to experiment with the pointing method. Begin by typing the = sign in D2, click on cell B2, type the sign, click on C2, and complete the formula by pressing R or clicking the green Ton the formula bar. 1 2 4 6 7 A B C D Item /kg kg cost potatoes 0.0 12 6.00 carrots 0.20 1.00 peas 0.2 1.2 apples 1.10 9 9.90 oranges 1.0 7 10.0 TOTAL 28.6 Figure It would be time consuming to repeat this for all the cells in column D. Instead, select D2 and note the small solid square in the lower, right corner. This is the fill handle. Position the cursor over the fill handle; you will know when you are there because the cursor changes from an open to a solid shape as shown below. Drag the fill handle down to cell D6. Microsoft Excel calls this operation filling but you can think of it as copying. Figure 4 Select the range A6:D6 and use the Border tool to add a double underline. The formula in D7 is =D2+D+D4+D+D. Or, you may wish to experiment with the AutoSum tool in preparation for learning about the SUM function. Cell References: Relative and Absolute When you look at the formula in D (recall that formulas may be viewed in the Formula bar), you will see that the formula that was copied from D2 (=B2 C2) has become =B C. This adjustment has occurred in all the cells in D:D6. Excel has adjusted the formulas because the cell references are relative. We may think of it in this way: In the formula =B2 C2 in D2, the reference to B2 is interpreted as the cell that is two columns to the right and on the same row as the cells containing the formula. So when the formula is copied to D, the reference to B2 is changed to B. Similarly, the reference to C2 is changed to C. Very often it is more convenient to name a cell as an alternative to using an absolute reference. We do not have space in the supplement to discuss this topic. There will be many instances when you do not wish a cell reference to be treated as relative, you wish the reference to remain unchanged. In the worksheet below, the formula in C1 is =B1 (1+$B$10). The dollar signs make the reference to B10 absolute. When

4 Formulas and Functions the formula is copied, the reference to $B$10 does not change. The formula in C1 may be copied down the column to give the correct result. The cells B1:C16 were formatted with the comma style tool. 10 11 12 1 14 1 16 A B C Increase 12.2% Item Old price New Price Computer 1,000.00 1,122.0 Monitor 12.00 140.1 Printer 200.00 224.0 Modem 8.00 9.41 Figure At other times you may require (i) the column part to vary while the row part of a reference remains fixed, or (ii) the row part to vary and the column part to be invariant. This can be done with mixed references. In the simple multiplication table shown below, the formula in K2 is =$J2 K$1. The dollar sign in front of the J holds the J constant as the formula is copied across the worksheet. The absence of a dollar sign in front of the 2 allows the row to vary as the formula is copied down the worksheet. In the second term (K$1), we keep the row constant as the formula is copied down the worksheet but allow the column to change as the formula is copied to the right. 1 2 4 6 Figure 6 J K L M N O 1 2 4 1 1 2 4 2 2 4 6 8 10 6 9 12 1 4 4 8 12 16 20 10 1 20 2 The $ signs may, of course, be typed in the normal way. Alternatively, you may begin by typing =J2 and then, by pressing 4 repeatedly, adjust the formula to the required =$J2. Worksheet Functions Microsoft Excel contains a large number of built-in functions to simplify your task. For example, the formula =SUM(B1:B100) will add the values in the range B1:B100. To use a function we give its name followed by a list of its arguments enclosed in parentheses. In the SUM example, B1:B100 is the single argument. Some functions have a fixed number of arguments, some have a variable number while a few have none. For example, the NA function takes no arguments so we could construct the formula =NA(). The rules about the arguments for a particular function are called the syntax. If you lookup SUM in the Help facility you will find its syntax is given as: SUM(number1, number2,...) The bold items are required, the others are optional. Obviously, the name of the function is required. If you misspell it, the cell will display the #NAME? error. You will get the same

Formulas and Functions error if you leave a space between the function name and the opening parenthesis. The bold number1 shows that the SUM function needs at least one argument and the values of this argument must be numeric. The function can have more than one argument. The ellipses (...) indicate that the second argument may be repeated as many times as you wish. There are rules that impose a limit but it is doubtful if you will ever attempt to exceed it. The formula =SUM(B1:B10, C1:C20, D1:D99) sums three ranges. Do not overwork the SUM function. The formula =SUM(A1/A2) will give the same result as =A1/A2. The simple formula is the correct one to use, the first one misuses the SUM function. You may use spaces between arguments. For example, to compute the payments on a loan with the PMT function we may code =PMT(A1/12, A2*12, 1000) with a space after each comma. However, we may not have a space between the function name and the opening parenthesis. The AutoSum Tool Because the need to sum a column or row of numbers is so common, Excel provides a shortcut way of performing the task. With the active cell at the bottom of a column of numbers or to the right of a row of numbers, click the AutoSum tool and Excel inserts a formula such as =SUM(B1:B12). The range used for the argument is shown by a range finder (coloured border). The user need only compete the entry by clicking the T on the Formula Bar or by pressing R or one of the navigation keys. If you prefer to use the keyboard rather than the mouse, the shortcut for the AutoSum tool is A+=. The Paste Function and Formula Palette Tools When you use a function with which you are familiar you may wish to construct the formula just by typing. In other cases, the Paste Function and Formula Palette tools are very helpful. To demonstrate its use we will make the worksheet shown below. This is a table showing the monthly payments on a 1,000 loan for various annual rates and times. 1 2 4 6 7 8 9 10 A B C D E F G Monthy payments on a loan Principal 1,000 Rate Years % 6% 7% 8% 9% 10% 1-8.61-86.07-86. -86.99-87.4-87.92 2-4.87-44.2-44.77-4.2-4.68-46.14-29.97-0.42-0.88-1.4-1.80-2.27 4-2.0-2.49-2.9-24.41-24.89-2.6-18.87-19. -19.80-20.28-20.76-21.2 Figure 7 The function we need is called PMT. We will look at financial function in detail in a later unit, we use the PMT function here to demonstrate the Function Palette It has the syntax =PMT(rate, nper, pv, fv, type), where rate is the interest rate being charge, nper is the

6 Formulas and Functions number of payments, pv is the present value (the amount of the loan.) The other, optional arguments need not concern us for now. What is important is that we recognize that payments will be made monthly and that the interest is computed by the bank on a monthly basis. Thus the annualised rate must be divided by 12 and the length of the loan in years must be multiplied by 12 to put everything on a monthly basis. We shall enter a formula in B6 and use the fill handle to complete the table. With B6 as the active cell, click on the Paste Function tool. This brings up the dialog box shown below. Figure 8 Excel divides its functions into categories. We need one of the financial functions so we click the appropriate item in the Function category panel (right hand side.) Then in the Function name panel (left hand side) we look for the required function. Excel provides a brief description of each function at the bottom of the dialog box which can be very helpful if you are unsure of the name of the required function. When the PMT function has been located either double click its name or single click the OK button to open the Function Palette dialog as shown below. Figure 9 This provides a list of the arguments together with a description of each. The required arguments are named in bold; the others are optional. If the Function Palette obscures the worksheet, click on the diagonal red arrow next to an argument s text box. This shrinks the

Formulas and Functions 7 dialog to a single text box (see below). Complete the text box by typing, by pointing or by a combination of both, then click the downward red arrow to re-expand the Formula Palette box. Figure 10 When you have completed all the required arguments, the result is displayed in two places on the box. Click the OK button to complete the formula. The cell B4 now contains the formula =PMT(B/12, A4*12, 1000). For the rate we have used B4/12 since the % value in B is the annual rate but the interest on a bank loan generally accrues monthly. For the number of periods in which interest will be computed and payment made, we have use A4*12 since A4 is in years and we need a value in months. Note that Excel displays the result in red to indicate an outgoing flow of cash. If you do not like the negative value edit the formula to read = PMT(B/12, A4*12, 1000). Editing a Formula When a simple formula needs to be changed one may merely re-type it. At other times it may be better to edit the existing formula. There are two ways to start the process: (1) double click on the cell, or (2) press 2. Once you are in edit mode (the Status Bar will display Edit rather than Ready) you can focus on either the cell or on the Formula Bar when making your changes. When a cell containing a formula is in edit mode, those cells that are referenced by the formula are outlined by coloured range finders as shown in the figure below. These provide an excellent, visual means of checking a formula. Figure 11

8 Formulas and Functions The formula in B6 of the worksheet above needs editing before it is copied because we wish the references to the row (row ), which has the rate values, and those to the column (column A), with the year values, to remain unchanged. The reference to B (the principal) must not change at all when we copy the formula. The correct formula is =PMT(B$/12, A$6*12, $B$). Double click B6 twice to move to Edit mode and adjust the references using the 4 key. Remember you can move about within the formula by clicking the mouse or by use of the l and r keys. Having returned to Ready mode by clicking the T in the Formula Bar, we may complete the table by dragging the fill handle of B6 down to row 10 and across to column G. Some Common Functions Excel places its functions into categories. Here we will look as some of the more commonly used functions in the Mathematical, Statistical and Financial categories. We will not look at the text, logical or engineering functions. Mathematical: ABS Returns the absolute value of a number the value without a sign. Thus if A1 contains the value 100, then =ABS(A1) returns the value 100. LOG Returns the logarithm of a number. If B2 contains the value 100, then =LOG(B2) returns the value 2. See the Excel Help facility for more on LN, LOG and LOG10. ROUND Returns a number rounded to the required level. The most common use in business calculations is to return a value to two decimal places since this is how we work with currency. The formula =ROUND(C1*1%, 2) find 1% of the value in C1 and rounds it to two decimal places. Note that we are permitted to perform calculations within the function. The formula =ROUND(C2, -2) returns the value in C2 rounded to the nearest hundred. The ROUND function uses the simple rule of round down when the value to be rounded is less than and round up otherwise. There is no function to round to an even number when the number to be rounded is exactly. Excel, does however, provide the functions ROUNDUP and ROUNDDOWN. SQRT Returns the square root of a positive number. If G1 contains the value 9, then =SQRT(G1) returns. IF G1 contains -9, the formula returns the #NUM! error value. SUM This function returns the sum of a range of values. Thus SUM(A1:A100) will sum all the numbers in the range A1:A100. Note that any non-numerical values in the range are ignored. Statistical AVERAGE Returns the average of a range. Thus =AVERAGE(A1:A20) returns the average value of the numbers in A1:A20. Non-numerical values are totally ignored. COUNT Returns a count of how many values there are in a range. If A1:20 has 6 numeric values and 14 text values then =COUNT(A1:A20) will return the value 6. See also COUNTA in Excel Help. LARGE Returns the k-th largest value in a range. The formula =LARGE(A1:A20,2)

Formulas and Functions 9 MAX MIN SMALL returns the second largest number in A1:A20. Returns the maximum value in a range. Returns the smallest value in a range Returns the k-th smallest value in a range; thus =SMALL(A1:A20, 2) returns the second smallest numerical value in A1:A20. Financial Many of the financial functions are concerned with the fact that the value of money varies with time. The present value (pv) is a value today while the future value (fv) is a value in the future. These two are related by the interest rate (rate) and the number of periods (nper) for the accumulation of compound interest. These terms (pv, fv, rate and nper) are used by Excel as the names of arguments and of functions. PV FV RATE PMT Suppose you have a financial document that states that the bearer will be given a sum of money (say, 1,000) in years time. This is the future value. How much is this worth today? What is its present value. The PV function will compute this but you must tell it what interest rate to use. You deposit a sum of money (say 1,000) in a savings deposit that pays a certain rate of interest monthly. How much will you have in the bank in years? The 1,000 is the present value. The FV function will compute the future value. If you know the present value and the future value (and the time between), the RATE function will compute the rate of return on the money. This function may be used to compute the periodic payments (generally, monthly) on a loan or to compute how much must be saved periodically in order to achieve a set goal. Getting Help with Worksheet Functions It is, unfortunately, not easy to get the Help facility of Excel 2000 to show you a list of all the worksheet functions. Here is one way to get a list of financial functions. Using either the Office Assistant or the Assistant Wizard tab in the full Help facility, search for PV. Open the open dealing with the PV worksheet on and within it click on See also. In the resulting dialog box, click on Financial functions. A complete list of Excel s financial worksheet functions is then displayed. To get a list of statistical functions, start the process with Average. Starting with Sum will get you the Mathematical and Trig functions. Nesting Formulas A formula may be used as an argument for another formula. This is called nesting. Suppose we have data in A1:A100 and need the sum of these numbers rounded to two decimal places. We could enter in A101 =SUM(A1:A100) and in A101 =ROUND(A101,2) in A101. However, nesting allows us to achieve the same result with one formula: we could use =ROUND(SUM(A1:A100), 2) in A101. It is important to learn how to interpret nested formulas for in that way you will learn how to use them. The functions are evaluated by Excel working from the inside to the outside. So in our case, Excel finds the sum and then rounds it two decimal places. Note how the evaluation is the same as if we had used two separate formulas.

10 Formulas and Functions The function in A1 is said to be nested to two levels - one or more of the arguments of the outside function is itself a function. We have a function within a function. Nesting is permitted up to seven levels. Here is another example. We have some data in columns A and B (say A1:A100 and B1:B100) and we wish to have the larger sum of the two in C1. We could use =SUM(A1:A100) in A101 and =SUM(B1:B100) in B101, and use =MAX(A101, B101) in C1. The alternative is to use in C1 =MAX(SUM(A1:A100), SUM(B1:B100)). Returning to the first example: we have found the rounded value of the sum of the numbers. Could we find the sum of the rounded values? That is to say, could we use =SUM(ROUND(A1:A100,2)). The answer is No! The syntax of ROUND is =Round(number, digits). The first argument must be a single number; it cannot be a range. The IF function The IF function has the syntax =IF(logical-test, true-value, false-value). It is easier to understand this with an example. The values in column B of Figure 12 represent the marks earned by students in a class. The IF function is used in column C. For example in C2 we have =IF(B2>=0,1, "Pass1","Fail"). The logical-test is B2>=0. Read this as test if B2 is greater than or equal to 0." When this logical-test is true, the function returns the value of the second argument. In our case this is the text Pass. When the logical-test is not true, the third argument is returned. The function has been changed in Figure 1 to read =IF(B2>=0,"Pass",""). The third argument is an empty text string. A B C 1 Student Mark Comment 2 Mary 0 Pass John 4 Fail 4 Anthony 60 Pass Henry 70 Pass 6 Jane 80 Pass Figure 12 A B C 1 Student Mark Comment 2 Mary 0 Pass John 4 4 Anthony 60 Pass Henry 70 Pass 6 Jane 80 Pass Figure 1 The logical-test has the form expression-2 comparison operator expression-2. The comparison operator are: Operator Meaning Example = (equal sign) Equal to A1=B1 > (greater than sign) Greater than A1>B1 < (less than sign) Less than A1<B1 >= (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

Formulas and Functions 11 <> (not equal to sign) Not equal to A1<>B1 You should convince yourself that these two formulas are equivalent: =IF(B2>=0,"Pass","Fail") and =IF(B2<0,"Fail","Pass"). The IF function may be nested up to seven levels. Suppose that the commission earned by a salesforce is governed by these rules: 1 2 4 6 7 8 9 A B C D E F G H Salesperson Sales Commission rate Commsssion Tim,000 2.% 7.00 =D2*C2 Joanna 6,000.0% 00.00 Nicky,00.0% 27.00 Justin 12,00 10.0% 1,20.00 Damian 8,000.0% 400.00 Figure 14 Sales Commission rate up to 4,999 2.%,000 to 9,999 % 10,000 and up 10% =IF(B2<000, 2.%, IF(B2<10000, %,10%)) In Figure 14 we find the commission rate and the actual commission. The formula in C2 is =IF(B2<000, 2.%, IF(B2<10000, %, 10%) ). In the outer IF we test to see if the sales figure is less than 000. If this is true then we return the value 2.% for the commission rate. If the test fails, we make a second test with the inner IF (note that it does not need an equal sign.) The inner IF tests if the sales is less than 000 and it returns % if the test is true or 10% if it is false. We could have coded this as =IF(B2>=10000,10%, IF(B2>=000, %, 2.%), or =IF(B2>9999.99,10%, IF(B2>4999.99, %, 2.%). When you find yourself coding an IF with more than two levels of nesting (i.e three or more IF s in one formula), you should read the Excel Help to learn how to use either HLOOKUP or VLOOKUP. Here is a more complicated IF problem. The commission is paid using these rules: Sales Commission rate first,000 2.%,001 to 10,000 % over 10,000 10% Figure 1 shows a possible solution. Of course, the last argument in C2's formula (000*2.%) could be replaced by the simple value 12. Once you are able to get a worksheet operating correctly you may wish to consolidate some of the formulas. In this

12 Formulas and Functions case, the four formulas in C2:F2 could be replaced by one formula: =IF(B2<001, B2*2.%, 12)+IF(B2<001, 0, IF(B2<10001, (B2-000)*%, 20)+IF(B2<10001, 0, (B2-10000)*10%) But formulas this large are error prone! 1 2 4 6 7 8 9 10 11 12 1 14 A B C D E F G H I J Salesperson Sales 2.%.0% 10.0% Total Tim,000 7.00 0.00 0.00 7.00 =SUM(C2:E2) Joanna 6,000 12.00 0.00 0.00 17.00 Nicky,00 12.00 2.00 0.00 10.00 Justin 12,00 12.00 20.00 20.00 62.00 Damian 8,000 12.00 10.00 0.00 27.00 Figure 1 =IF(B2<001, 0, IF(B2<10001, (B2-000)*%, (10000-000)*%)) =IF(B2<001, B2*2.%, 000*2.%) =IF(B2<10001,0, (B2-10000)*10% Array Functions As you get more proficient with Excel you will meet functions which return values to more than one cell. These are called array functions. There are two important steps when entering an array function: 1) Before typing the formula, you must select the range of cells required by the function. 2) Once you have entered the function it must be completed using the three keys C+S+R. DO NOT try to complete the function using the green check mark in the Formula bar. Error values Sometimes when you enter a formula, Excel returns one of its error message values indicating that something is wrong. Error value Meaning ###### The column is too narrow to display the result. The solution is (a) alter the format to show fewer decimal places or (b) make the column wider #VALUE! One of the arguments in a formula has the wrong type. For example if A1 contains text and B1 the formula = A1/2, B1 will display #VALUE!

Formulas and Functions 1 #DIV/0! #NAME! #N/A An attempt has been made to divide by zero (the operation is said to be undefined). Suppose column A contains last years sales values for various items and B contains this years. In C you are computing the percentage change with the formula =(B2-A2)/A2. This formula has been copied down the column. But there are some new items this year so some of the A values are zero and the #DIV/0! results. Change the formula to =IF(A2>0, (B2-A2)/A2, NA()) or =IF(A2>0, (B2-A2)/A2, ). The most common reason for this is a typo error. Thus if you enter =AVEREGE(A1:A100) you will get this error message - you meant to type AVERAGE. This is not always an error. It simply means not applicable or not available - see the example under #DIV/0! above. #REF! Suppose B2 contains the formula =A2*2 and you copy this to A. Excel cannot adjust the reference to A2 since there is no column to the left of column A. The cell will display the #REF! error. #NUM! #NULL! This results when a non-numeric value is used as a numeric argument in a function. This results when Excel cannot determine which intersection is being referenced - a topic beyond the scope of these notes. Giving Names to Cells The worksheet in Figure 16 is used to compute the pay for casual workers. The formulas used are: D8: =B8*C8 E8: =ROUND(D8*$B$,2) F8: =$B$+$B$4 The $ symbols are used to make absolute references so that we may copy the formulas in D8:F8 down to row 1. 1 2 4 6 7 8 9 10 11 12 1 A B C D E F G Payroll calculation Union.00 Health 10 Tax 12.0% Staff Rate Hours Gross Tax Other Net Nicky 12.7 446.2.78 1.00 7.47 Justin 1.00 4 64.00 80.6 1.00 49.7 Rebecka 1.00 2 2.00 40.6 1.00 269.7 Daniel 14.0 4 62.0 77.94 1.00 0.6 Tim 1.90 486.0 60.81 1.00 410.69 Jo 12.7 29 69.7 46.22 1.00 08. Figure 16

14 Formulas and Functions The alternative to using absolute references is to name the cells. This has a number of advantages. The primary one is to reduce errors. It is very easy to make a typo and enter something like F when you meant B. However, if the cell B has a name such as Union you need not remember its location; its name tells you its purpose. In addition, naming cells makes it easier to refer to cells on different sheets. To name the cells in B:B with the names in A:A begin by selecting A:B and use the command Insert Name Create. This opens the dialog box shown in Figure 17. You may find the text in this box misleading: Create names in Left column. If you read this as: Create names from Left column it may make more sense to you. Generally, Excel automatically picks the correct location for the names. Click the OK button. Figure 17 We will look at two ways of using the newly created names. The first method is the one to use if the names are created in a worksheet before their cells are referenced. Delete the formula in E8 and retype it as =ROUND(D8*Tax,2). There is a slightly quicker way that saves you having to type the name. You will recall that cell references may be entered into formulas using the point-and-click method. When a cell has a name, this method automatically uses its name rather than its reference. Delete the entry in E8 and type =ROUND( then click on D8, type a period, click on B and complete the formula. Note how the name Tax appears. The second way is generally used when you name a cell after using its reference in formulas. Select F8:F1 and use the command Insert Name Apply to bring up the dialog box shown in Figure 18. Click the OK button we do not have space here to go into the options on the dialog. Within the selected range, all references to cells with names are now replaced by their respective names. We have looked at single cells with names. We may also name ranges. For example we could name G8:G1 as Net. This name could be used in a formula such as =SUM(Net). So far we have used names that appear as text labels and have used the command Insert Name Create to make these names. If you do not wish to have actual names on the worksheet use the command Insert Name Define to name a cell or a range. To see a list of named cells and ranges use the command Insert Name Paste Paste List. Be sure that the cursor is at the top of an unused area of your worksheet when you do this, otherwise the output could overwrite previously entered material. Remember the Undo button when disaster strikes. There are special rules for valid names but we will follow some simple ones: 1) start the name with a letter of the alphabet and 2) use only letters and digits and the underscore

Formulas and Functions 1 character in a name. You cannot use a name that could be mistaken for a cell reference (such as X1.) If you use the Insert Name Create method with such a name in one of the text cells, Excel will actually call it X1_. This is, an underscore is added to the name. The same applies to the two names R and C; these become R_ and C_. Note that names are not case sensitive, so TAX, Tax and tax are the same name. A name defined on one sheet may be referenced on another. If two sheets have cells with the same name then the name specific to the sheet is used in formulas. If two sheets define cells using the same name do not try to refer to either of them in a third sheet. The Danger of Range Labels Starting with Excel 97, it became possible to use range labels in formulas. So for example, without making any special provision (i.e. without creating or defining names) we could in cell D8 of the worksheet shown in Figure 16 use the formula =Rate*Hours in place of =B8*C8. When this feature was introduced it was sometimes referred to natural language formulas. However, it is possible to have too much of a good thing! Because the range label could mean a single cell or the entire range depending where it was used, too many people made some bad mistakes. In Excel 2000 this feature is, by default, switched off. To turn it on (and do this only after careful thought!) use the command Tools Options, open the Calculation tab and check the Allow labels in formulas box. You are urged to deselect this after experimenting with it.