56
S.I. Krishan Excelvbacomputing.wordpress.com More Excel Basic

Intro to Excel Basics: Part II

Embed Size (px)

Citation preview

Page 1: Intro to Excel Basics: Part II

S.I. KrishanExcelvbacomputing.wordpress.com

More Excel Basic

Page 2: Intro to Excel Basics: Part II

Presentation Topics

• Cell Referencing• Moving and Copying Formulas• Cell Referencing by Name• Worksheet Functions• Function Categories• Function Examples• Setting Precision for Calculations• Dealing with Errors

Page 3: Intro to Excel Basics: Part II

Cell Referencing

• Two Styles of Referencing– A1 vs. R1C1 Notation

• The A1 notation is the commonly used cell referencing notation in Excel. This is the notation we have been using and will continue to use. However, Excel also supports another notation, known as R1C1 notation.

• In R1C1 notation, a cell is specified by two numbers: Row number and Column number. Thus, cell A2 will be referenced as R2C1, meaning its R number is 2 and C number is 1. Similarly, cell B2 will be referred as R2C2. Some more examples are:

• C3 as R3C3• B4 as R4C2• D6 as R6C4

Page 4: Intro to Excel Basics: Part II

Range Referencing

• A range of cells in Excel implies a rectangular group of contiguous cells

• Specify by referencing the top left cell in the range, followed by a colon, and the bottom right cell.

A11:B14

B3:D8

Page 5: Intro to Excel Basics: Part II

Referencing Cells on Other Sheets in the Same Workbook

• You can refer to cells in other worksheets in the same workbook. This is done by inserting the sheet name followed by an exclamation mark (!) before the usual cell reference

• Some examples are:– Sheet2!A3 references cell A3 of worksheet 2– The formula =A2+Sheet2!B2+Sheet3!C2 adds cell A2 of the

active sheet with cell B2 of Sheet2 and cell C2 of Sheet3– The formula =Sheet2!B2*Sheet3!A3 multiplies cell B2 of

Sheet2 with cell A3 of Sheet3

• You can also refer to cells on worksheets in other workbooks. Such References to cells in other workbooks are called external links and the referenced workbooks are called linked workbooks or files.

Page 6: Intro to Excel Basics: Part II

Referencing Cells From Other Workbooks

• When you refer to a cell or a group of cells in another workbook, the referenced workbook is called the source workbook. The workbook making the reference is called the destination workbook.

• [Bills.xlsx]Sheet2!B1 refers to cell B1 of sheet 2 in the workbook named Bills.xlsx. The workbook Bills.xlsx in this case is the source workbook. This will work only when the source workbook is open.

• If the source workbook is closed, then the complete path to the source workbook file must be given. For example:– 'C:\Personal\[Taxes.xlsx]Sheet1'!E10– Note that the path reference to the closed workbook is enclosed within

single quotation mark

Page 7: Intro to Excel Basics: Part II

Relative and Absolute Cell Referencing Modes

• Cell references such as A1 represent relative referencing mode. When a formula containing relative referencing is copied, the references in the copied formula are automatically adjusted.– Example: Suppose the formula =A1+B1 is entered in

cell C1. Next, the formula is copied into cells C2 and C3. Excel will automatically adjust the formula in C2 as =A2+B2, and in C3 as =A3+B3

– If we copy the formula =A1+B1 into cell G1, it will be adjusted to =E1+F1 because the position of cell E1 relative to cell G1 is identical with that of cell A1 with C1. The same is true for F1’s relative position being identical to that of cell B1

Page 8: Intro to Excel Basics: Part II

Relative and Absolute Cell Referencing Modes

• Cell references such as $A$1 represent absolute referencing. When a formula containing absolute referencing is copied, the cell references in the copied formula do not change.– Example: Suppose the formula =$A$1+$B$1 is entered in

cell C1. Next, the formula is copied into cells C2 and C3. Excel will keep the formula cell references unchanged. Thus, the formula in C2 will appear as =$A$1+$B$1, and C3 will show the same

• You can mix absolute and relative referencing. For example, you can specify a cell reference as $A1. This is called column absolute. Similarly you can have row absolute referencing as in A$1

Page 9: Intro to Excel Basics: Part II

Moving and Copying Formulas

• Excel behaves differently when you cut and paste a formula than when you copy and paste a formula

When you cut and paste a formula, the effect is that of moving the formula. No updating of cell references in the formula takes place

Page 10: Intro to Excel Basics: Part II

Paste Button Options

• Paste or Formulas option implies pasting the copied formula

• Paste Values option causes the formula result to be pasted instead.

• Paste Link option implies that the formula result will be pasted but Excel will update the result if the result of the formula in the source cell changes

Page 11: Intro to Excel Basics: Part II

• The AutoFill feature of Excel allows you to enter a series of numbers, months, and days in consecutive cells

• To use this feature, you must fill in two consecutive cells to let Excel know the pattern for AutoFill

• The filling takes place when you select the first two cells of the series and drag the fill handle over the cells you want to fill

• The AutoFill feature is also used for copying a formula

AutoFill Handle

AutoFill Feature

Page 12: Intro to Excel Basics: Part II

Fahrenheit (F) to Celsius (C) ConversionDegree in F Degrees in C

20 -6.7

• Enter 20 and 40, respectively in cells A3 and A4. Select cells A3 and A4 and drag the fill handle over cells A5:A9

• Enter the formula for temperature conversion in cell C3. The formula is =(A3-32)*5/9. Note A3 is representing temperature in Fahrenheit that is being converted.

• Now select cell C3 and drag its fill handle over C4:C9 to generate a table of equivalent temperatures

Temp in Celsius =(Temp in Fahrenheit -32)*5/9

AutoFill Example: Temperature Convertor

Page 13: Intro to Excel Basics: Part II

Relative and Absolute Referencing Example

• Create a multiplication table where the cells in blue show the result of multiplying a pair of numbers. The numbers in each pair are taken from yellow cells along the respective rows and columns.

• In cell B2, enter the formula =$A2*B$1. The formula has mixed referencing because numbers in the multiplication formula remain the same along columns and rows, respectively.

• Copy the formula along rows and columns to fill the table.

1 1 2 3 4 5 6 7 8 92345 156789

10 10 20 30 40 50 60 70 80 90

Column Absolute

Row Absolute

Page 14: Intro to Excel Basics: Part II

Multiplication Table: Formulas View

• The formula view shows the formulas that are automatically entered by Excel in each cell upon copying the formula of cell B2. You can note how a number in each pair of multiplicands remains same either along each row or column

• See what will happen if you used only relative referencing in B2 and then copied the formula to other cells

1 1 2 3 4 5 6 7 82 =$A2*B$1 =$A2*C$1 =$A2*D$1 =$A2*E$1 =$A2*F$1 =$A2*G$1 =$A2*H$1 =$A2*I$13 =$A3*B$1 =$A3*C$1 =$A3*D$1 =$A3*E$1 =$A3*F$1 =$A3*G$1 =$A3*H$1 =$A3*I$14 =$A4*B$1 =$A4*C$1 =$A4*D$1 =$A4*E$1 =$A4*F$1 =$A4*G$1 =$A4*H$1 =$A4*I$15 =$A5*B$1 =$A5*C$1 =$A5*D$1 =$A5*E$1 =$A5*F$1 =$A5*G$1 =$A5*H$1 =$A5*I$16 =$A6*B$1 =$A6*C$1 =$A6*D$1 =$A6*E$1 =$A6*F$1 =$A6*G$1 =$A6*H$1 =$A6*I$17 =$A7*B$1 =$A7*C$1 =$A7*D$1 =$A7*E$1 =$A7*F$1 =$A7*G$1 =$A7*H$1 =$A7*I$18 =$A8*B$1 =$A8*C$1 =$A8*D$1 =$A8*E$1 =$A8*F$1 =$A8*G$1 =$A8*H$1 =$A8*I$19 =$A9*B$1 =$A9*C$1 =$A9*D$1 =$A9*E$1 =$A9*F$1 =$A9*G$1 =$A9*H$1 =$A9*I$110 =$A10*B$1 =$A10*C$1 =$A10*D$1 =$A10*E$1 =$A10*F$1 =$A10*G$1 =$A10*H$1 =$A10*I$1

Page 15: Intro to Excel Basics: Part II

Creating a Table Calculating Area of a Right Angle Triangle Given Base and Height

2 4 6 8

2

5 =4*5/2

8

11

Page 16: Intro to Excel Basics: Part II

Using Names for Cell Referencing

• Excel permits a cell or a range of cells to be assigned a name which can be then used in a formula. The main advantage of this Excel feature is that it makes easy to understand the calculations being done by a formula

Income = Revenue - Expenses

C1 = A1 – B1 Vs.

Page 17: Intro to Excel Basics: Part II

How to Create and Use Names?

• Select a cell or range• Click Name box• Type the name we want to use in the Name box and press

Enter• Naming rules

– No spaces are allowed within a name. Use an underscore (_) symbol to avoid spaces

– A name must begin with a letter or underscore– Numbers can be included but not at the beginning– Not case sensitive. So “base” or “BASE” or “Base” are all considered

same

Page 18: Intro to Excel Basics: Part II

Example: Name Use for Triangle Area

Worksheet for Calculating the Area of a Right Angle Triangle Table

5 10 15 2048

Triangle 12Base 16

Triangle Height

Page 19: Intro to Excel Basics: Part II

MORE EXCEL: PART TWOWORKSHEET FUNCTIONS

Page 20: Intro to Excel Basics: Part II

Worksheet Functions

• A worksheet function is a series of complex calculations that come packaged with Excel.

• The details of the calculations performed by a function are hidden from the user.

• Excel provides over 300 worksheet functions that make it easy for users to perform complex calculations for a variety of applications

• We can also write custom functions using Visual Basics for Applications (VBA ) in those situations where Excel does not have an appropriate function.

Page 21: Intro to Excel Basics: Part II

Parts of a Worksheet Function

• A worksheet function has two components: a name and a list of arguments enclosed in a pair of parentheses as shown in some examples below

SUM(A1, A2, A3)MAX(B1, B2, 5)SQRT(A5)SUM(B1:B10)

• Arguments are constants, cell addresses or ranges, or other functions or arithmetic expressions

• A worksheet function either appears by itself as a formula or as a part of a formula as shown in some examples below=AVERAGE(B1:B8)=SUM(A1:A5)/5=10 – SQRT(A2)=SUM(A1, A2-2,A3*A4)

Page 22: Intro to Excel Basics: Part II

Worksheet Functions (Continued)

• Different functions require different arguments. For example, the RAND function has no argument. SQRT has one argument, and you can have up to 255 arguments for many functions such as SUM and AVERAGE

• When entering functions, make sure you do not put space between the function name and the opening parenthesis of the argument list

Page 23: Intro to Excel Basics: Part II

Entering Functions in Formulas

• By manually typing the function name and its arguments. When entering manually, Excel helps you by Formula AutoComplete feature

Page 24: Intro to Excel Basics: Part II

Insert Function Dialog Box

• You can also enter function through the Insert Function dialog box

• The dialog box appears when you click the Insert function button in the Formula bar or in the Ribbon when Formulas tab is active

Page 25: Intro to Excel Basics: Part II

Insert Function Dialog Box (2)

Page 26: Intro to Excel Basics: Part II

Function Nesting

• Nesting means using one or more functions as arguments of other functions. Two examples of nesting are shown below

=SUM(A1,SUM(A2,SUM(A3:A5)))

=AVERAGE(SUM(A2,SQRT(A3*A5)), MAX(A1,A2,5))

Page 27: Intro to Excel Basics: Part II

Function Categories

• Excel has 12 different categories of functions. Many of these categories are shown in the Ribbon when Formulas tab is active

Page 28: Intro to Excel Basics: Part II

Common Function Examples

• AVERAGE(number1,number2,…) Returns the average of its arguments

• ABS(number)Returns the absolute value of its argument

• SQRT(number)Returns the square root of a number

• SUMSQ(number1,number2,…)Returns the sum of the squares of the arguments

Page 29: Intro to Excel Basics: Part II

More Function Examples

• ROUND(number,num_digits)Rounds a number to the specified number of digits after

the decimal point.

=ROUND(4.6737,0) 5

=ROUND(4.6737,1) 4.7

=ROUND(4.6737,2) 4.67

=ROUND(4.6737,3) ?

Page 30: Intro to Excel Basics: Part II

More Function Examples

• CEILING(number,significance)Rounds a number up, to the nearest integer or to the

nearest integer multiple of significant.

=CEILING(4.67,1) 5=CEILING(4.67,2) 6=CEILING(4.67,.25) 4.75=CEILING(4.67,3) ?

6 is the nearest integer to 4.67 that is divisible by 2

4.75 is the nearest integer multiple of 0.25 greater than 4.67.

6

FLOOR(number, significance) behaves similarly except that it goes for a smaller number

Page 31: Intro to Excel Basics: Part II

More Function Examples

=FLOOR(4.67,1) 4=FLOOR(4.67,2) 4=FLOOR(4.67,.25) 4.50

4 is the nearest integer less than 4.67 that is divisible by 2

4.50 is the nearest integer multiple of 0.25 less than 4.67.

FLOOR(number, significance) behaves similarly to the CEILING except that it goes for a smaller number

Page 32: Intro to Excel Basics: Part II

More Function Examples

• INT(number)Rounds a number down to the nearest integer.

=INT(4.87) 4

=INT(4.13) 4

=INT(5/3) 1

=INT(5/2) ? 2

Page 33: Intro to Excel Basics: Part II

More Function Examples

• MOD(number,divisor)Returns the remainder after division.

=MOD(4,3) 1=MOD(4.13,3) 1.13

=MOD(5,3.3) 1.7

=MOD(14,7) ? 0

Page 34: Intro to Excel Basics: Part II

More Function Examples

• QUOTIENT(numerator,denominator) Returns

the quotient of a division.

=QUOTIENT(6,3) 2=QUOTIENT(4.13,3) 1=QUOTIENT(35,10) 3=QUOTIENT(19,5) ? 3

Page 35: Intro to Excel Basics: Part II

MORE EXCEL PART 3: WORKSHEET EXAMPLES

Page 36: Intro to Excel Basics: Part II

Illustrative Example: Calculating Distances

• We are given a worksheet with five pairs of points. Each point is represented by two values, the X and Y coordinates

• The goal is write formulas using suitable worksheet functions to calculate distances between each point pair

• Three different distance measures are to be used for each pair

Page 37: Intro to Excel Basics: Part II
Page 38: Intro to Excel Basics: Part II

Distance Measures

• Euclidean distance– This is the common distance measure we use

between two points. It measures the length of the line joining the two points

– The formula for the Euclidean distance isEuclidean Distance (Point 1, Point 2) = [(x1-x2)2 + (y1-y2)2]1/2

P1

P2

Page 39: Intro to Excel Basics: Part II

Distance Measures(2)

• City Block distance– This measure uses the length around the city

blocks as you go from one point to another. – The formula for the City Block distance is

City Block Distance (Point 1, Point 2) = |(x1-x2)| + |(y1-y2)|

P1

P2

Page 40: Intro to Excel Basics: Part II

Distance Measures(3)

• Chess Board distance– This measure treats points as positions on a chess board.

The minimum number of valid chess moves needed to go from one point to another is treated as the distance between two points

– The formula for the Chess Board distance isChess Board Distance (Point 1, Point 2) = Max (|(x1-x2)|, |(y1-y2)|)

P1

P2

Or

Page 41: Intro to Excel Basics: Part II

Initial Worksheet for Distance Calculations

Pair Number X1 Y1 X2 Y2 Euclidean Distance

City Block Distance

Chess Board Distance

1 5.85 6.71 14.54 7.842 10.25 3.33 7.34 18.653 29.67 12.43 -3.56 -5.824 -14.42 16.75 -5.25 -7.55 12.25 6.67 8.75 24.76

Page 42: Intro to Excel Basics: Part II

Writing Formulas for Distance Calculations Worksheet

• We will use names in place of cell references• We will assign names using the Define Name

button in the Formulas tab

Page 43: Intro to Excel Basics: Part II

Using the Define Name Button

• Select the cells you want to name. We select B1:B6• Click the Define Name button• Enter the name in the New Name dialog box. We will

enter XCORD1• Repeat for other groups of cells

Page 44: Intro to Excel Basics: Part II

Distance Calculation Formulas

• For Euclidean distance (Cell F2), and copied to F3:F6=SQRT(SUMSQ((XCORD1-XCORD2), (YCORD1-YCORD2)))

• For City Block distance (Cell G2), and copied to G3:G6=ABS(XCORD1 - XCORD2) + ABS(YCORD1 - YCORD2)

• For Chess Board distance (Cell H2), and copied to H3:H6=MAX(ABS(XCORD1 - XCORD2), ABS(YCORD1 - YCORD2))

Page 45: Intro to Excel Basics: Part II

Final Worksheet for Distance Calculations

Page 46: Intro to Excel Basics: Part II

Another Example: Returning Exact Change

• We have a worksheet with column A showing the amount to be returned as change

• The change is returned using the minimum number of one dollar bills, quarters, dimes, nickels, and pennies. For example, change of $2.27 will be returned with two one dollar bills, one quarter, and two pennies

Page 47: Intro to Excel Basics: Part II

FLOOR Function Recapped

• We will solve the exact change problem using the FLOOR function. It is also possible to use other functions, for example the INT function to solve it

• Why FLOOR function?– Because it rounds a number down to the nearest integer or to the

nearest integer multiple of significance

=FLOOR(2.27,1) 2 (Two one dollar bill)

=FLOOR(0.27,0.25) 1 (One quarter)

=FLOOR(0.02,0.01) 2 (Two pennies)

Page 48: Intro to Excel Basics: Part II

Exact Change Formulas

• Cell A4 has the change amount• The number of one dollar bills needed is calculated in cell B4

using the formula=FLOOR(A4,1)

• The number of quarters is calculated in cell C4. The formula is=FLOOR(A4-B4,0.25)/0.25

• Similar formulas for dimes, nickels, and pennies in cells D4:F4 are=FLOOR(A4 – B4 – C4*0.25, 0.10)/0.10=FLOOR(A4 – B4 – C4*0.25 – D4*0.10, 0.05)/0.05=(A4 – B4 – C4*0.25 – D4*0.10 – E4*0.05)/0.01

Page 49: Intro to Excel Basics: Part II

Completed Exact Change Worksheet

Page 50: Intro to Excel Basics: Part II

Setting Precision for Calculations

• Some times you will find Excel returning incorrect answers in cases where arithmetic operations on extremely small quantities are performed. You might encounter such a situation in your exact change worksheet for certain amounts

• As another example of getting an unexpected result, consider the following formula

=1*(.5-.4-.1)You would expect Excel to return 0 as the result. However, Excel will return the

result as -2.78E-17, which is the scientific notation for -0.0000000000000000278 .

• The reason for above and similar results in Excel is how it internally represents the fractional numbers. Such errors are known as rounding errors

Page 51: Intro to Excel Basics: Part II

Dealing with Rounding Errors

• We deal with rounding errors by setting precision, a measure that tells Excel the level of accuracy we desire in our calculations

• You can control precision in two ways– Using the ROUND function. For example, round off the

calculations by replacing the formula =1*(.5-.4-.1) with =ROUND(1*(.5-.4-.1),2). This rounds off results to two decimal places

– Using the Excel Options button. Here select the Advance category and then When calculating this workbook section, and then checking the Set precision as displayed box

Page 52: Intro to Excel Basics: Part II

Setting Precision in the Exact Change Worksheet

• You can avoid rounding off errors by setting precision to two decimal places as we are dealing with money here. You can do so by using the following formulas for nickels and pennies

=FLOOR(ROUND((A4 - B4 - C4*0.25 - D4*0.1),2), 0.05)/0.05

=ROUND((A4 - B4 - C4*0.25 - D4*0.1 - E4*0.05),2)/0.01

Page 53: Intro to Excel Basics: Part II

Dealing with Errors

• Excel provides a few options to deal with errors. You can access these options via the Excel Options button and the Formulas category

Page 54: Intro to Excel Basics: Part II

Error Values in Excel

Error Value Explanation#DIV/0! This error value is caused by trying to perform a division by zero.#NAME? This error value is generated when a formula contains an undefined

variable or function name. Often this error value results from a misspelled function name.

#N/A This error value is generated by a special group of functions when no proper answer is available.

#NULL! This error value implies that the result of the calculation has no value.

#NUM! Excel generates this error value if it finds that one or more values supplied to perform a cal culation are not of proper type. For example, Excel might be expecting a numerical value but it is supplied with a non-numerical value.

#REF! This error occurs when a formula uses an invalid cell reference. For example, this error will occur if you delete a cell referred to in the formula.

#VALUE! Excel generates this error value whenever an incorrect argument or operator is specified in a formula.

##### This error message is displayed when a column is not sufficiently wide or a negative date or time value is present.

Page 55: Intro to Excel Basics: Part II

Locating Error Sources

• Excel provides a group of commands in the Formula Auditing panel to help you locate error source in worksheets with many complex calculations

Page 56: Intro to Excel Basics: Part II

THANK YOU