CS Excel
CS Excel
SPREADSHEET
Presents a grid of cells, each of which can
BASICS contain text or numerical data, or results of
computation.
1 2
Excel 2016
Optional Readings:
http://www.dssresources.com/history/sshistory.html
http://www.dssresources.com/history/mattessichspreadsheet.ht
m
Video: Cringely, Robert X. Triumph of the Nerds. Ambrose Video,
1996. (on OWL)
3 4
Fundamental Ideas Fundamental Ideas
» Cells » Cells
» Data » Data
» Coordinates » Coordinates
» Formulas » Formulas
5 6
7 8
Coordinates Fundamental Ideas
9 10
Formulas Formatting
11 12
Formatting Formatting
• Cells may be formatted using Data values may be presented many ways.
13 14
Formatting Formatting
Data values may be presented many ways. • It is appropriate to format cells properly
• Select the cells to format and choose the appropriate formatting option
from the menu bar
• Changes are made using formatting buttons on the Home tab.
Changes include:
▫ formatting rate as a percentage
▫ formatting a cell as currency
▫ using bolding and centering on table titles
▫ changing the font size and the color on the worksheet’s title
• Other formatting options also exist
15 16
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
Formulas Formulas
Enter an equation that Excel will compute:
Using Cell Reference:
starts with an equal (=) sign
= A6 + B8
arithmetic
operands Take the values
(+, - , *, /, etc ) currently in
cell A6 and B8
constants
add them together
-or-
cell references
place the results in
cell A11
17 18
Formulas Formulas
19 20
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
Formulas Formulas
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Relative reference Relative reference
cell reference example:
changes based on
direction and copy the contents
number of cells of cell A11
to cell B12
example:
copy the contents over to the right
of cell A11 1 cell
to cell B12
A in A6 becomes B
B in B8 becomes C
21 22
Formulas Formulas
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Relative reference Relative reference
example: example:
copy the contents copy the contents
of cell A11 of cell A11
to cell B12 to cell B12
23 24
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
Formulas Formulas
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Relative reference Relative reference
example: example:
Relative Reference Rules:
copy the contents copy the contents
of cell A11 of each
for cell cell
A11moved to the RIGHT : Add (+) One (1) to the COLUMN
to cell B10 to cell B10
for each cell moved to the LEFT: Subtract (-) One (1) from the COLUMN
1 cell over and 1 cell 1 cell over and 1 cell
up upeach cell moved DOWN: Add (+) One (1) to the ROW
for
for each cell moved UP: Subtract (-) One (1) from the ROW
add 1 to each add 1 to each
COLUMN value COLUMN value
subtract 1 from subtract 1 from
each ROW value each ROW value
25 26
Formulas Formulas
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Absolute reference Absolute reference
cell reference cell reference
remains the same
regardless of remains the same
direction and regardless of
number of cells direction and
number of cells
absolute referencing
requires the use of the example:
absolute symbol ($) copy the contents
of cell A11
to cell B12
preceding the
reference to be ‘anchored’
27 28
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
Formulas Formulas
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Absolute reference Absolute reference
example: example:
copy the contents copy the contents
of cell A11 of cell A11
to cell B12 to cell B12
29 30
Formulas Formulas
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Absolute reference Absolute reference
example: example:
copy the contents
copy the contents of cell A11
of cell A11 to cell B10
to cell B12
1 over and 1 up
absolute reference absolute reference
values do values do
NOT change NOT change
regardless of
regardless of direction and number
direction and number of cells
of cells
31 32
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
Formulas Formulas
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Mixed reference Mixed reference
row or column row or column
is relative is relative
and and
column or row column or row
is absolute is absolute
33 34
Formulas Formulas
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Mixed reference Mixed reference
row or column row or column
is relative is relative
and and
column or row column or row
is absolute is absolute
35 36
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
Mixed reference Mixed reference
row or column row or column
is relative is relative
and and
column or row column or row
is absolute is absolute
37 38
Copy and Paste - Using Cell Reference: Copy and Paste - Using Cell Reference:
=$A6 + B$8
Mixed reference Multiplication Table
row or column create a single formula
is relative
and to be placed in
column or row
is absolute cell B8
that will compute the
example:
copy the contents results of multiplying
of cell D13 the row by the column
to cell B14
so that it can be copied
WHAT IS THE FORMULA THAT IS NOW IN CELL B14 ? and paste to all cells
39 40
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
Copy and Paste - Using Cell Reference: - Professor develops a formula to correctly calculate
the overall marks for the students
Mixed reference
Multiplication Table
- Professor enters formula for the 1st student
BRUTE FORCE
enter individual - Once formula tested for the 1st student, formula
formulas in each cell copied into the cells for all the students in the class
- yech !!!
41 42
Formulas (Question) - Calculate the marks Formulas (Question) - Calculate the marks
Formula: ( (70 x 0.25) + (80 x 0.25) + (90 x 0.50) ) = 82.5 Formula: ( (70 x 0.25) + (80 x 0.25) + (90 x 0.50) ) = 82.5
43 44
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
45 46
47 48
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
Formulas (Question) - Calculate the marks Formulas (Question) - Calculate the marks
copy and paste ( pull down ) the original formula copy and paste ( pull down ) the original formula
49 50
Formulas (Question) - Calculate the marks Formulas (Question) - Calculate the marks
change just the exam weights - averages change automatically ! change just the exam weights - averages change automatically !
51 52
Copy and Paste Copy and Paste of Formulas
• When pasting formulas, cell references like A10 are
relative!
• Can copy or move the contents and the • That is, the row and column are taken as offsets from
formatting of cells from one place to another. where the original formula was placed.
copy paste
• Absolute references are “fixed” when pasted/dragged: • Absolute references are “fixed” when pasted/dragged:
Calculate total precipitation in Cell D1 and Calculate total precipitation in Cell D1 and
paste it into cells D3 to D9 paste it into cells D3 to D9
59 60
Example 1: Part 1 Example 1: Part 2
Calculate total precipitation in Cell D1 and Calculate the difference between the total precipitation
paste it into cells D3 to D9 for each city and the total record precipitation.
61 62
Seems to work
for this cell!
Calculate the difference between the total precipitation Calculate the difference between the total precipitation
for each city and the total record precipitation. for each city and the total record precipitation.
63 64
Example 1: Part 2 Example 1: Part 2
Referencing wrong
cell!
Calculate the difference between the total precipitation Calculate the difference between the total precipitation
for each city and the total record precipitation. for each city and the total record precipitation.
65 66
Calculate the difference between the total precipitation Calculate the average for each student using the
for each city and the total record precipitation. number of students in cell B1.
69 70
Example 2: Example 2:
Calculate the average for each student using the Calculate the average for each student using the
number of students in cell B1. number of students in cell B1.
71 72
Example 2: Example 2:
Calculate the average for each student using the Calculate the average for each student using the
number of students in cell B1. number of students in cell B1.
73 74
Example 2: Example 2:
Calculate the average for each student using the Calculate the average for each student using the
number of students in cell B1. number of students in cell B1.
77 78
Operators Operators
Examples
79 80
Operators Example 3:
Examples
83 84
Activity
Solutions:
EXCEL TUTORIAL
BOOLEAN LOGIC
85 86
87 88
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
IF (today is Tuesday) AND (it is September) IF (today is Tuesday) AND (it is September)
THEN I will bake an apple pie THEN I will bake an apple pie
OTHERWISE (else) I will bake a pumpkin pie OTHERWISE (else) I will bake a pumpkin pie
89 90
IF (today is Tuesday) AND (it is September) IF (today is Tuesday) AND (it is September)
THEN I will bake an apple pie
THEN I will bake an apple pie
OTHERWISE (else) I will bake a pumpkin pie
OTHERWISE (else) I will bake a pumpkin pie
boolean variable: (today is Tuesday)
boolean variable: (it is September)
((today is Tuesday) AND (it is September)) is a boolean expression boolean operator: AND
boolean expression: ((today is Tuesday) AND (it is September))
91 92
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
93 94
95 96
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
97 98
99 100
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
» Selects between one of two actions » Selects between one of two actions
True or False True or False
» Student earning a mark greater than or equal to 50
» Requires three parts ( sections ) : will be given a numeric grade for the course.
If they have a mark less than 50
=IF(<expression>,<true>,<false>) they will be given an “F”.
⋄ <expression> is a Boolean expression » Mark for a student is stored in cell G68
⋄ <true> part performed if expression is true
⋄ <false> part preformed if expression is false Formula:
=IF(G68>=50,G68,”F”)
⋄ decides if a numeric grade or an “F” is given
101 102
103 104
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
105 106
Formula: Formula:
=IF (B5<= 1000, B5*.05, IF (B5 <=5000, B5*.10, B5*.15)) =IF (B5<= 1000, B5*.05, IF (B5 <=5000, B5*.10, B5*.15))
107 108
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
109 110
Excel Functions
What is a Function?
• Similar to but not the same as functions in math
EXCEL TUTORIAL f(x) = 10x + 5
f(x, y) = x2 + y2
EXCEL FUNCTIONS • Less rules for functions in computer science:
– Functions can have no parameters
=ROW()
– Same arguments can have different output
=RANDBETWEEN(10, 20)
111 112
Excel Functions Excel Functions
113 114
115 116
Excel Functions Excel Functions
Why do we Need Functions? Function Parts
• Functions allow us to reuse code someone else has =SUM(number1, [number2], …)
already made for us.
• Can do repetitive or tedious work for us. Function Parameters
Name
• Don’t have to understand the inner workings of the
function, just how to use it.
• Can do calculations or access data not possible with
just operations.
– Example: =NOW()
117 118
=SUM(number1, [number2], …) Update student average example (EX #2) using functions SUM
and COUNT.
Function Parameters =SUM(number1, [number2], …)
Name Arguments
Add the given numbers.
=COUNT(value1, [value2], …)
=SUM(A1, 32, 5.124, B$5, $C$6) Counts the number of numbers it is given.
Text is not counted.
119 120
Excel Functions Excel Functions
Example 5: Example 5:
Update student average example (EX #2) using functions SUM
and COUNT.
=SUM(number1, [number2], …)
Example: =SUM(5, 10, 13.5) 28.5
=COUNT(value1, [value2], …)
Example: =COUNT(5, “cat”, 13.5, “”) 2
121 122
125 126
=AVERAGE(number1, [number2], …)
• Returns the average of the given numbers
• As with many Excel functions, the arguments can be
cell constant values, cell references, or cell ranges.
127 128
Excel Functions Excel Functions
Example 5: Take 3 More Functions
Function(s) Description
MAX, MIN, MINIFS, Find the largest (max) or smallest (min) number given.
MAXIFS
AVERAGE, AVERAGEA, Find the average of the given numbers/range.
AVERAGEIF
STDEV.P, STDEV.S Find the standard deviation of a population (STDEV.P) or sample (STDEV,
STDEV.S).
SUM, SUMIF Find the sum of the given numbers/range (i.e. add them together).
COUNT, COUNTA, Count the number of numbers or text in the given range.
COUNTIF
DATEDIF, DAYS Find the number of days between two given dates.
PMT Calculates the payment for a loan based on constant payments and a constant
interest rate.
Many, many, more…. See Last Slide for More
129 130
Excel Functions
Online Help
https://support.office.com/
135 136
Excel Functions Excel Functions
Online Help Online Help
https://support.office.com/ https://support.office.com/
137 138
If a student’s grade is
greater than or equal to
60 output PASS in
column C. Otherwise
output FAIL.
139 140
Logic Functions Logic Functions
Example 6: Example 7:
141 142
143 144
“_IF” Functions “_A” Functions
» Variant of functions like AVERAGE, COUNT, MIN, MAX, etc. that allow arguments to be
nonmembers (e.g. text).
SUMIF(range, criterion, [sum range]) » Examples:
SUMIF(A2:A5, “>160”) ⋄ AVERAGEA, COUNTA, MINA, MAXA, etc.
adds values from A2:A5 if they are greater than 160
145 146
=PMT(rate,nper,pv,fv,type)
rate – interest rate
nper – total # of payments
pv- present value (principal)
fv – future value, default =0
Ignores text
type - indicates when payment is due
0 – (default) at end of the period
1 – at the beginning of the period
Treats text
as 0s
147 148
MIS – Spreadsheets– MS Excel MIS – Spreadsheets– MS Excel
149 150
Requires three arguments: Returns a value in the same row from a column you specify
- numeric value (or cell) to look up to the right of the column containing the value found.
- range of the table
- column number containing the value to return Use VLOOKUP when your comparison values are located
- mode / range_lookup (optional - default value) in a column to the left of the data you want to find.
151 152
Look Up Functions Look Up Functions
VLOOKUP Example 11:
=VLOOKUP(value, table, offset, mode)
value is the item you are looking for Find Linda’s location
table is the lookup table
offset is the position of the column within
the table with the related value
153 154
- look at the column with the names - look at the column with the names
- find Linda’s - find Linda’s
- move across two columns to find her location is ‘Sudbury’ - move across two columns to find her location is ‘Sudbury’
155 156
Look Up Functions Look Up Functions
Example 11: Example 11:
=VLOOKUP(“Linda”, D4:F9, 3 , FALSE) =VLOOKUP(“Linda”, D4:F9, 3 , FALSE)
157 158
D4:F9 – specifies the ‘table area’ D4:F9 – specifies the ‘table area’
to look in to look in
Looks up a value in a ‘table area’ & returns a related Searches for a value in the uppermost row of a table
value
Returns a value in the same column from a row you specify
Requires three arguments: below the row containing the value found.
- numeric value (or cell) to look up
- range of the table Use HLOOKUP when your comparison values are located
- row number containing the value to return in a row below the data you want to find.
- mode / range_lookup (optional - default value)
161 162
165 166
C3:F6 – specifies the ‘table area’ C3:F6 – specifies the ‘table area’
to look in to look in
167 168
Look Up Functions Look Up Functions
Example 12: Example 12:
=HLOOKUP(“Wrangler”, C3:F6, 3 , FALSE) =HLOOKUP(“Wrangler”, C3:F6, 3 , FALSE)
169 170
171 172
Referencing Multiple Worksheets Referencing Multiple Worksheets
Use the value in a cell on one worksheet on a different cell Use the value in a cell on one worksheet on a different cell
in another worksheet. in another worksheet.
example: example:
=Sheet2!E3 =IF(PayScale!E3>25,C10,Sheet2!F9)
173 174
175