1. CS 105
Spreadsheet Computations
What is a cell? What is a range?
What is a formula?
What is a circular reference?
What’s the difference between copying text
and copying a formula?
CS 105 Spring 2011
#1
2. Manipulating Data
• A calculator can store two numbers and do
simple manipulations
current
M
memory clear
memory recall
memory set
memory plus
Mem clear
Set M to zero
M=0
Mem recall
Set current to M
current = M
Mem set
Set M to current
M = current
Mem plus
Set M to M + current M = M + current
CS 105 Spring 2011
#2
3. Manipulating Spreadsheet Data
• A workbook contains worksheets(spreadsheets).
A spreadsheet stores data organized in cells,
and can do complex data manipulation.
Name box
active cell
formula bar
fill handle
The cell location is referred to as its cell reference.
CS 105 Spring 2011
#3
4. Cell Ranges
An adjacent range is a rectangular block of cells and can
be as small as a single cell.
G2 : G8
Single
Column
Range
column letters
A1
Single cell
A3 : E3
Single Row Range
B6:E13
Read as
“B6 to
E13”
Row numbers
CS 105 Spring 2011
#4
5. Cell contents can be either
Data or Formulas
• Data can be either Numeric or Strings:
– numbers (e.g. 25.32, -56, $78, 1.02E-3, 5%, 1/1/2011)
– strings (e.g., Total, Angelina Jolie, 1-217-244-0000)
• Formulas always begin with an equals = and can contain
operators, data, cell references, ranges and functions,
e.g.
= 1+ A1
• Cells also have formatting attributes
CS 105 Spring 2011
#5
6. Numbers as strings
• Some “numbers” are
entered as text
(strings):
– zip codes
– phone numbers
– social security
numbers
– Such numbers do not
get involved in
computation.
By default Excel left-justifies strings and right-justifies numbers.
CS 105 Spring 2011
#6
7. Date Entries
• Dates are a special kind of number – Try
01/01/1900
• Two-digit year values 00 through 29 are
interpreted as the years 2000 through 2029
• Year values 30 through 99 are interpreted
as the years 1930 through 1999.
CS 105 Spring 2011
#7
10. Operators in Formulas
• Arithmetic operations (in order of precedence)
– parentheses
( )
– negation (as in -1)
– exponentiation
^
– multiplication, division
*
/
– addition, subtraction
+
-
CS 105 Spring 2011
# 10
11. Hierarchy of Arithmetic Operations in
Excel
– Scan the formula from left to right
– Evaluate what is in parentheses first
– Operations of highest priority are done first
– Evaluate from left to right operations of equal priority.
= B1 + B2 * C3
= -C1 ^ A1
= (B3-A1)*A1^2/B2
CS 105 Spring 2011
# 11
12. Functions in Formulas
• =TODAY()
• =MONTH( March 7, 2006)
• =MONTH(A1)
CS 105 Spring 2011
# 12
13. Bad Formulas!!! Circular References
• When a formula references itself
(either directly or indirectly) there is
a Circular Reference
• When this happens, Excel warns you
several times!!
• BAD:
CS 105 Spring 2011
# 13
14. Copying formulas
• Example: In a Sudoku board, every row must sum to 45
– more conditions, but we’ll stick to this for now
• Copy formula to the remaining rows (formula changes)
CS 105 Spring 2011
# 14
15. When you cut and paste a
cell that is referenced in a formula,
then again the formula changes
CS 105 Spring 2011
# 15
16. Copying/Pasting Formulas
Relative Cell Reference
• A cell reference that adjusts automatically
when it is copied.
• By default, formulas that you enter use
relative cell references.
• For example:
B to D = moved 2 Columns
2 to 5 = moved 3 Rows
CS 105 Spring 2011
# 16
17. Mixed Cell References
• A cell reference that refers to an exact
location on the worksheet and does not
adjust when copied.
• Cell reference is preceded by a dollar sign.
• For example:
=($B$5 + $C7) * D$9
Absolutely column b
and absolutely row 5
Absolutely
column c
CS 105 Spring 2011
Absolutely
row 9
# 17
19. To Summarize:
• What is a cell? What is a range?
• What is a formula?
• What is a circular reference?
• What’s the difference between copying text
and copying a formula?
CS 105 Spring 2011
# 19