Handout Presentation Slides Unlocked
Handout Presentation Slides Unlocked
Formulas and
Functions
=B2*C2
1
1
7/5/2015
Using Absolute Cell References • If the worksheet name in the reference includes
one or more spaces, you must enclose it in single
quotation marks.
• For example, here’s a formula that refers to a cell
on a sheet named All Depts:
=A1*’All Depts’! A1
• Referencing cells in other workbooks
• To refer to a cell in a different workbook, use this
format:
=[WorkbookName]SheetName!CellAddress
Notice that the reference to B6 is • Example of a formula that uses a cell reference in
an absolute reference i.e. $B$6 the Sheet1 worksheet in a workbook named
Budget:
Referencing cells outside the • If the workbook is closed, however, you must add
worksheet the complete path to the reference so that Excel
can find it. Here’s an example:
• Referencing cells in other worksheets
=A1*’C:\My Documents\[Budget For
• To use a reference to a cell in another worksheet
in the same workbook, use this format: 2008.xlsx]Sheet1’!A1
SheetName!CellAddress • A linked file can also reside on another system
• Example of a formula that uses a cell on the that’s accessible on your corporate network.
Sheet2 worksheet: • The formula below, for example, refers to a cell in
=A1*Sheet2!A1 a workbook in the files directory of a computer
• This formula multiplies the value in cell A1 on the named DataServer.
current worksheet by the value in cell A1 on
Sheet2.
=’\\DataServer\files\[budget.xlsx]Sheet1’!$D$7
2
2
7/5/2015
• While the sheet has linkage with external • To create a drop‐down list in a cell:
workbook, we have to check the update of the 1. Enter the list items into a single‐row or single‐
data. column range. These items are the ones that
• Click on Data =>>Refresh all =>> to Update all the appear in the drop‐down list.
information in the workbook that is coming from 2. Select the cell that will contain the drop‐down
a data source list and access the Data Validation dialog box.
3 In the Settings tab
3. tab, select the List option and
• We can check the connection, open the source specify the range that contains the list using
file and break the linkage if we do not need to the Source control.
update in future. 4. Make sure that the In‐Cell Dropdown check
box is checked.
5. Set any other Data Validation options as
desired.
Validation
True if its numeric argument is an odd number. Notice
that the formula refers to the active cell, which is cell B2.
• 5. Click the Error Alert tab and choose Stop for the Style
and type An odd number is required here as the Error
Message.
• 6. Click OK to close the Data Validation dialog box.
3
3
7/5/2015
=IF(A1="A",1,IF(A1="B",2,IF(A1="C",3,"")))
• This formula checks cell A1. If it contains "A", the formula returns 1. If
it doesn't contain "A", then the second argument is evaluated. The
second argument contains another IF function that determines if A1
contains a "B". If so, the formula returns 2; if not, the formula
evaluates the IF function contained in the second argument and checks
to see if A1 contains "C". If so, it returns 3; otherwise, it returns an
empty string.
• Excel allows up to seven levels of nested IF functions. The formula
below works correctly, but Excel will not allow you to nest the IF
functions any deeper than this.
=IF(A1="A",1,IF(A1="B",2,IF(A1="C",3,IF(A1="D",4,IF(A1="E",5,IF(A1=
"F",6,IF(A1="G",7,IF(A1="H",8,""))))))))
• The sections that follow present various ways to get around the limit of
seven nested IF functions. Be aware that these techniques may not be
appropriate for all situations.
Note:
Excel 2007 and later allows up to 64 nesting level
4
4
7/5/2015
Working with
Dates
and Times =DATE(A2,B2,C2)
• =DATE(2012,1,5)
5
5
7/5/2015
6
6
7/5/2015
Homework
=DATEDIF(A1,TODAY(),”Y”)
Calculation Chart for Depth less than Half of
Calculation of Fuel Volume in Diameter
a Horizontal Cylindrical Tank Y X Strip Area Cum. Area Volume
PREPARED BY : SR JYAKHWA
(mm) (mm) (mm2) (mm2) (Liter)
Maximum Diameter of Calculation is 4000mm 0 0
1 59 30 30 0 Full Capacity of Tank = 15701.7 Liter
Description Input 2 84 71 101 0 Half Volume of Tank = 7850.8 Liter
Outer Diameter of Tank (D) = 3500 mm 3 102 93 194 1 Volume of Fuel = 357.8 Liter
Outer Length of Tank (L) = 1632 mm 4 118 110 304 1 Inner Diameter of Tank = 3500 mm
Wall Thickness (T) = 0 mm 5 132 125 430 1 Depth of Air in Tank = 3300 mm
Depth of Fuel (H) = 200 mm 6 145 138 568 2
7 156 151 719 2 If Depth of Fuel is More than Half of
Depth of Fuel (H)= 200 mm 8 167 162 880 3 Volume of Fuel = #N/A Liter
Inner Radius of the Tank = 1750 mm 9 177 172 1053 3
Inner Length of the Tank = 1632 mm 10 187 182 1235 4
Volume of Fuel in Tank = 357.8 Liter 11 196 191 1426 5
12 205 200 1626 5
13 213 209 1835 6
14 221 217 2052 7
15 229 225 2277 7
=DATEDIF(B20,TODAY(),"Y") 16
17
236
243
232
240
2509
2749
8
9
18 250 247 2996 10
19 257 254 3249 11
20 264 260 3510 11
21 270 267 3777 12
22 277 273 4050 13
23 283 280 4330 14
7
7
7/5/2015
Creating
Some Formulas That
Formulas Count and
Sum
Round
Example
A B
1 Formula Description (Result) • Generally, a counting formula returns the
2 =ROUND(2.15, 1) Rounds 2.15 to one decimal place (2.2) 2.15 2.2
3 =ROUND(2.149, 1) Rounds 2.149 to one decimal place (2.1) 2.149 2.1490
number of cells in a specified range that meet
4 =ROUND(-1.475, 2) Rounds -1.475 to two decimal places (-1.48) ‐1.475 ‐1.48 certain criteria.
5 =ROUND(21.5,
( -1)) Rounds 21.5 to one decimal place to the left of the decimal point ((20)) 521.5 0
• A summing formula returns the sum of the
values of the cells in a range that meet certain
LEFT
criteria.
Data
1 Sale Price Sale Swed
2 Sweden Sweden weden
3 Formula Description (Result)
=LEFT(B31,4) First four characters in the first string (Sale)
8
1
7/5/2015
• ISERR: Returns TRUE if the cell contains any Counting cells by using multiple criteria
error value except #N/A
• ISNA: Returns TRUE if the cell contains the
#N/A error value
• Examples,
• {=SUM(IF(ISERROR(data),1))}
{ SUM(IF(ISERROR(data),1))}
• The following formula returns the number of
#DIV/0! error values in the range named Data:
• =COUNTIF(Data,”#DIV/0!”)
• =COUNTIF(Data,”#VALUE!”)
9
2
7/5/2015
• Using And criteria • to count the number of sales that meet the
• to count cells that contain a value greater than following criteria:
100 and less than or equal to 200.
• Month is January, or
• =COUNTIFS(Amount,”>100”,Amount,”<=200”)
• SalesRep is B, or
• {=SUM((Amount>100)*(Amount<=200))}
• Amount is greater than 1000
• to count the number of sales that meet the
following criteria: • The solution is :
• Month is January, and • {=SUM(IF((Month=”January”)+(SalesRep=”B”)+(A
• SalesRep is B, and mount>1000),1))}
• Amount is greater than 1000
=COUNTIFS(Month,”January”,SalesRep,”B”,Amount,”
>1000”)
• An alternative formula, which works with all • Combining And and Or criteria
versions of Excel, uses the SUMPRODUCT • to count sales that meet the following criteria:
function. The following formula returns the same • Month is January, and
result as the previous formula.
• SalesRep is B, or SalesRep is C
• =SUMPRODUCT((Month=”January”)*(SalesRep=”
B”)*(Amount>1000))
• Another way to perform this count is to use an • The formula is:
array formula: • {=SUM((Month=”January”)*IF((SalesRep=”B”)+
{=SUM((Month=”January”)*(SalesRep=”B”)*(Amou (SalesRep=”C”),1))}
nt>1000))}
10
3
7/5/2015
11
4
7/5/2015
=IF(B2<>"",SUM(B$2:B2),"")
12
5
7/5/2015
13
6
7/5/2015
• Using Or criteria
• One of Excel’s most interesting (and most
• Suppose that you want to get a sum of past‐due
powerful) features is its ability to work with
invoice amounts or ones associated with the
Banepa office. arrays in formulas.
• This example requires an array formula: • An array is simply a collection of items
• {{=SUM(IF((Office=”
( (( Banepa”)
p )+ operated on collectively or individually.
(Difference<0),1,0)*Amount)} • In Excel, an array can be one dimensional
• A plus sign (+) joins the conditions; you can or two dimensional.
include more than two conditions. • These dimensions correspond to rows and
columns.
14
7
7/5/2015
• formulas in column D
• The following array formula is in cell C10:
=B2*C2
• {=SUM(B2:B7*C2:C7)}
• You can’t insert a multicell array formula into a • If you enter the array into a horizontal range
range that has been designated a table. that consists of more than five cells, the extra
• You designate a table using the Excel 2007 Insert cells will contain #N/A.
➪ Tables ➪ Table command).
• The following example is another horizontal
• In addition, you can’t convert a range that array; it has seven elements and is made up of
contains a multicell array formula to a table.
text strings:
• The formula is entered into all six of the selected
cells. {“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”}
• If you examine the Formula bar, you see the • To enter this array, select seven cells in a row and
following: type the following (followed by Ctrl+Shift+Enter):
{=B2:B7*C2:C7} • ={“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”}
• Excel places curly brackets around the formula to
indicate that it’s an array formula.
15
8
7/5/2015
Two‐dimensional arrays
• A two‐dimensional array uses commas to
separate its horizontal elements and semicolons
to separate its vertical elements.
• The following example shows a 3 × 4 array
constant:
{1 2 3 4;5 6 7 8;9 10 11 12}
{1,2,3,4;5,6,7,8;9,10,11,12}
• Displaying this array in a range requires 12 cells.
To enter this array into a range, select a range of
cells that consists of three rows and four
columns. Then type the following formula,
followed by Ctrl+Shift+Enter:
={1,2,3,4;5,6,7,8;9,10,11,12}
16
9
7/5/2015
• You can use the Excel TRANSPOSE function Creating an array from values in a range
to insert a horizontal array into a vertical
range of cells.
• {=TRANSPOSE(ArrayName)}
• You also can access individual elements
f
from th
the array b
by using
i th the EExcell INDEX
function.
• The following formula, for example, returns
the fourth item in the DayNames array:
• =INDEX(DayNames,4)
{={2,"dog",3;4,5,"cat";7,8,9;"eagle",11,12}}
17
10
7/5/2015
18
11
7/5/2015
• col_index_num: The column number within the table • The HLOOKUP function’s arguments are as follows
from which the matching value is returned. • lookup_value: The value to be looked up in the
• range_lookup: Optional. If TRUE or omitted, an first row of the lookup table.
approximate match is returned. (If an exact match is • table_array: The range that contains the lookup
not found, the next largest value that is less than table.
lookup_value is returned.) If FALSE, VLOOKUP will
search for an exact match. If VLOOKUP can’t find an • row_index_num: The row number within the table
exact match, the function returns #N/A. f
from which
hi h the
th matching
t hi value
l isi returned.
t d
• Note: • range_lookup: Optional. If TRUE or omitted, an
• If the range_lookup argument is TRUE or omitted, the first
approximate match is returned. (If an exact match
column of the lookup table must be in ascending order. If is not found, the next largest value less than
the range_lookup argument is FALSE, the first column of lookup_value is returned.) If FALSE, VLOOKUP will
the lookup table need not be in ascending order. search for an exact match. If VLOOKUP can’t find
an exact match, the function returns #N/A.
19
12
7/5/2015
20
13
7/5/2015
CommTable1 CommTable2
=C2*D2
=VLOOKUP(C2,IF(B2<3,CommTable1,CommTable2),2)
GradeList
=VLOOKUP(B2,GradeList,2)
=VLOOKUP(B2,{0,”F”;40,”D”;70,”C”;80,”B”;90,”A”},2)
=LOOKUP(B2,{0,40,70,80,90},{“F”,”D”,”C”,”B”,”A”})
21
14
7/5/2015
• An alternative method uses a single formula (an • You can’t insert a multicell array formula into a
array formula) to calculate all six values in D2:D7. range that has been designated a table.
• This single formula occupies six cells and returns an • You designate a table using the Excel 2007 Insert
array of six values. ➪ Tables ➪ Table command).
• To create a single array formula to perform the • In addition, you can’t convert a range that
calculations, follow these steps:
contains a multicell array formula to a table.
1. Select a range to hold the results. In this case, the
range is
i D2:D7.
D2 D7 • The formula is entered into all six of the selected
cells.
2. Enter the following formula:
=B2:B7*C2:C7
• If you examine the Formula bar, you see the
following:
3. Press Ctrl+Shift+Enter to enter the formula.
Normally, we press Enter to enter a formula. {=B2:B7*C2:C7}
• Because this is an array formula, however, press • Excel places curly brackets around the formula to
Ctrl+Shift+Enter. indicate that it’s an array formula.
22
1
7/5/2015
23
2
7/5/2015
Naming Array Constants • You can use the Excel TRANSPOSE function
to insert a horizontal array into a vertical
• You can create an array constant, give it a range of cells.
name, and then use this named array in a • {=TRANSPOSE(ArrayName)}
formula. • You also can access individual elements
• A named array can be created with the help of f
from th
the array b
by using
i th the EExcell INDEX
the New Name dialog box. (Access this dialog function.
• box by choosing Formulas ➪ Defined Names • The following formula, for example, returns
➪ Define Name.) the fourth item in the DayNames array:
• =INDEX(DayNames,4)
24
3
7/5/2015
• If the array is stored in a range (such as A1:C4), • A two‐dimensional array entered into a range in
the array formula returns the square of each A1:D3 is
value in the range, as follows: • {={1,2,3,4;5,6,7,8;9,10,11,12}}
{=A1:C4^2} • The TRANSPOSE function formula in A6:C9 is
• The following array formula, which you can • {=TRANSPOSE({1,2,3,4;5,6,7,8;9,10,11,12})}
enter into a 10‐cell vertical range, calculates the • You can, of course, use the TRANSPOSE function
square root of each array element in the array t transpose
to t an array stored
t d iin a range. The
Th
constant: following formula, for example, uses an array
{=SQRT({1;2;3;4;5;6;7;8;9;10})} stored in A1:C4 (four rows, three columns).
• If the array is stored in a range, an array formula • You can enter this array formula into a range
such as the one that follows returns the square that consists of three rows and four columns.
root of each value in the range: • {=TRANSPOSE(A1:C4)}
{=SQRT(A1:A10)}
25
4
7/5/2015
Creating a Pivot Table • Click OK, and Excel creates an empty pivot table
and displays its PivotTable Field List
• Specifying the data
• If your data is in a worksheet range, select any
cell in that range and then choose Insert ➪
Tables ➪PivotTable.
Questions
• What is the daily total new deposit amount for each
branch?
• How many accounts were opened at each branch,
broken down by account type?
• What’s the dollar distribution of the different account
Introducing
VBA Macros
types?
• What types of accounts do tellers open most often?
• How does the Central branch compare to the other two
branches?
• In which branch do tellers open the most checking
accounts for new customers?
26
5
7/5/2015
27
6
7/5/2015
28
1
7/5/2015
29
2