Upload
dd
View
21
Download
0
Embed Size (px)
Citation preview
# 1
CS 105 Spreadsheet
Computations
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
# 2
Manipulating Data• A calculator can store two numbers and
do simple manipulations
memory clear
memory recall
memory set
memory plus
current
M
M = M + currentSet M to M + current
M = currentSet M to current
current = MSet current to M
M = 0Set M to zero
Mem plus
Mem set
Mem recall
Mem clear
CS 105 Spring 2011
# 3
• A workbook contains worksheets(spreadsheets). A spreadsheet stores data organized in cells, and can do complex data manipulation.
Name box
The cell location is referred to as its cell reference.
formula baractive cell
fill handle
Manipulating Spreadsheet Data
Manipulating Spreadsheet Data
CS 105 Spring 2011
# 4
B6:E13
Cell RangesCell Ranges
Row numbers
column letters
G2 : G8 Single
Column Range
Single Row Range
A3 : E3
Read as “B6 to E13”
A1Single cell
An adjacent range is a rectangular block of cells and can be as small as a single cell.
CS 105 Spring 2011
# 5
• 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
Cell contents can be either Data or Formulas
Cell contents can be either Data or Formulas
CS 105 Spring 2011
# 6
• 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.
Numbers as strings Numbers as strings
CS 105 Spring 2011
# 7
Date Entries 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
# 8
Formatting a two-digit date
Formatting a two-digit date
CS 105 Spring 2011
# 9
Formula view:
Format cell as a number, not a date
Date Calculations
CS 105 Spring 2011
# 10
Operators in Formulas Operators in Formulas
• Arithmetic operations (in order of precedence)– parentheses ( )– negation (as in -1) -– exponentiation ^– multiplication, division * /– addition, subtraction + -
CS 105 Spring 2011
# 11CS 105 Spring 2011
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
# 12
• =TODAY()• =MONTH( March 7, 2006)• =MONTH(A1)
Functions in FormulasFunctions in Formulas
CS 105 Spring 2011
# 13
Bad Formulas!!! Circular References
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
# 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
# 15
When you cut and paste a cell that is referenced in a formula, then again the formula changes
CS 105 Spring 2011
# 16
• 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
Copying/Pasting FormulasRelative Cell Reference Copying/Pasting FormulasRelative Cell Reference
CS 105 Spring 2011
# 17
• 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
Mixed Cell References
Absolutely column b and absolutely row 5
Absolutely column c
Absolutely row 9
CS 105 Spring 2011
# 18
Copying/Pasting FormulasMixed Cell References
Copying/Pasting FormulasMixed Cell References
What happened when these formulas were copied?
CS 105 Spring 2011
# 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