Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

4/8/2013

1
Ibrahim Alameddine Ibrahim Alameddine
Microsoft Office Excel 2007
Excel is part of the Microsoft Office suite and many
others like Word, PPT, etc.
Excel helps you analyze analyze information information for informed
decisions by providing a comprehensive set of tools to
create create tables tables & & charts, charts, writing writing formulas formulas, etc.
Document
Window/
Workbook
Title Bar
Ribbon Ribbon
MS Office Button MS Office Button
Quick Access Toolbar Quick Access Toolbar
Status Bar
4/8/2013
2
Excel Workbooks
An Excel document is referred to as a workbook workbook (WB) (WB) and is
made of one or more worksheet(s) worksheet(s) (WS) (WS) or what we often
call spreadsheets spreadsheets
A WS resembles a table with columns labeled by letters letters and
rows by numbers numbers (e.g. A1)
Users can add, delete, rename, copy and move worksheets
Only one WS can be active active at anytime in a WB
A WS can be activated by clicking on its corresponding tab
LIMITS of a WS
Excel has a limit to the size of its WS Excel has a limit to the size of its WS
Maximum worksheet size:
65,536 Rows 65,536 Rows
256 Columns 256 Columns (A, AA, etc)
active sheet
non-active sheets scroll bars
row 11 11
c
o
l
u
m
n
JJ
Excel Worksheet: Cells
Worksheets are made of cells cells, each identified by
intersecting intersecting column column and and row row, e.g. C3, G10, etc
A cell can be activated by clicking on it
The name of the active cell is shown in the name
box
Clicking on any other cell will cause the currently
active to be deactivated
4/8/2013
3
active cell
nonactive cell
name box
formula bar
D6
F12
Range
Specify a range name
in the Name Box
You can name a range and use it in an equation
Groups:
Clipboard
Font
Alignment
Number
Styles
Cells
Editing
Home Ribbon
4/8/2013
4
Pasting in Excel
Copy paste a cell with a formula will: Copy paste a cell with a formula will:
Paste the formula and its value in Excel
Only the value outside Excel
Paste special: Paste special:
Formula
Value
Other options
Alignment Group
Alignment Types Alignment Types:
Horizontal alignment
Vertical alignment
Text Direction Text Direction
Wrap text Wrap text
Merge cells Merge cells
Click the cell or cells you want to align
Click on the options within the Alignment group on the Home Home
Ribbon Ribbon
There are several options for alignment of cell contents:
Top Align Top Align: Aligns text to the top of the cell
Middle Align Middle Align: Aligns text between the top and bottom of the cell
Bottom Align Bottom Align: Aligns text to the bottom of the cell
Align Text Left Align Text Left: Aligns text to the left of the cell
Center Center: Centers the text from left to right in the cell
Align Text Right Align Text Right: Aligns text to the right of the cell
Orientation Orientation: Rotate the text diagonally or vertically
Decrease Indent Decrease Indent: Decreases the indent between the left border
and the text
Increase Indent Increase Indent: Increase the indent between the left border and
the text
ALIGNING CELL CONTENTS
MERGING CELLS
Select the cells you want to merge
Click the Merge & Center button on the Alignment group Alignment group
of the Home Ribbon Home Ribbon
4 choices for merging cells: 4 choices for merging cells:
Merge & Center Merge & Center: Combines the cells and centers the contents in the
new, larger cell
Merge Across Merge Across: Combines the cells across columns without centering
data
Merge Cells Merge Cells: Combines the cells in a range without centering
Unmerge Cells Unmerge Cells: Splits the cell that has been merged
Merged cell will only retain the retain the
data of the left cell data of the left cell
(Merge before inputting data)
4/8/2013
5
Wrapping Text
Allows you to overcome overflowing content in your
cells
Wrap Wrap
Modify Text Fonts
To modify a text font:
1. Select the cell or cells that you would like the font applied
2. On the Font Font group on the Home Ribbon Home Ribbon, choose the font
type, size, bold, italics, underline, or color
Add Borders to Cells
To add borders manually:
Click the Borders Borders drop
down menu on the Font
Group of the Home
Ribbon
Choose the appropriate
border
More options Click
More Borders
1
2
3
Add Colors/Fill to Cells
To apply colors manually:
Click Fill drop down menu on Font Group Font Group of Home Ribbon Home Ribbon
Choose the appropriate color
1
2
3
4/8/2013
6
Apply Borders & Colors using Styles
To apply borders and colors using styles:
1. Click Cell Styles Cell Styles on the Home Ribbon Home Ribbon
2. Choose a style or click New Cell Style New Cell Style
1
2
3
Home
Ribbon
Conditional Formatting
It is hard to read and interpret data by scanning rows
and rows of information Colors Colors can can help help
Use conditional formatting to make data stand out
Help analyze data analyze data and identify patterns & trends identify patterns & trends
Apply bars Apply bars
Length of bar Value
Apply colors Apply colors
Color Value
Apply symbols Apply symbols
Symbol Value
You can apply multiple conditional formatting multiple conditional formatting in a single
WS
Conditional Formatting
(Setting Rules)
Excel Built in rules Excel Built in rules
Conditional Formatting
(Setting Rules)
You can also build your own rules
1. Select rule type
2. Edit rule description
(choose formatting)
All rules are All rules are
automatically updatable automatically updatable
1
2
4/8/2013
7
Conditional Formatting & Format as
Table
Conditionally format cells Conditionally format cells Format cells as styled table Format cells as styled table
Click Conditional Formatting
on the Home Ribbon
Choose a rule, e.g. highlight
a cell if Number <10 , etc.
Click Format as Table on the
Home tab
Choose a style
Insert/Delete Rows and Columns Insert/Delete Rows and Columns
Insert a row or column Delete a row or column
Click the Insert button Insert button on
the Cells Group of the Home
Ribbon
Click Insert Sheet, Rows or
Columns
Click the Delete button on
the Cells Group of the Home
tab
Click Delete Sheet Rows or
Columns
Those two options insert an entire row or entire column of cells. Those two options insert an entire row or entire column of cells.
To insert cells, click Insert Cells and then choose either Shift To insert cells, click Insert Cells and then choose either Shift
Cells Down or Right Cells Down or Right
Change Column Width and Row Height
Click the Format button Format button on the Cells
Group of the Home Ribbon Home Ribbon
Manually adjust the height and width
by clicking Row Height or Column
Width
Use AutoFit AutoFit::
Click AutoFit Row Height or AutoFit
Column Width
Hide/Unhide Rows and
Columns
Hiding rows or columns is an easy way to fold away fold away
information
Hiding columns is useful in maintaining complete records in a
single file helpful in big tables
To hide or unhide rows or columns:
Select the row or column you wish to hide or unhide
Click the Format button Format button on the Cells Group of the Home Ribbon
Click Hide & Unhide Hide & Unhide
(You can also right click and choose Hide/Unhide)
You can also hide a sheet!
4/8/2013
8
Hiding
Move/Copy A Sheet
To copy and move a worksheet around in a workbook:
Right-click on the worksheet you already created
Click Move or Copy Sheet
Can also be done in the Home Ribbon, in the Cells Group:
Click Format, and then under Organize Sheets Organize Sheets
Click Move or Copy Sheet
To make a copy: In the Move or Copy dialog box, select the
Create a Copy Create a Copy check box
The worksheet is duplicated in the workbook, and the sheet
name indicates that it is a copy
To move a sheet, just select where to move the sheet to
(move to end can be applied)
You can also drag and drop the sheet to move it
Move/Copy A Sheet
Right Click and choose Right Click and choose
Under Format Button Under Format Button
Rename A Sheet
Right click the sheet and choose rename
Under the Home Ribbon, in the Cells Group:
Click Format Format
Under Organize Sheets Organize Sheets
Click Move or Copy Sheet
4/8/2013
9
Number Format
You can define the format type format type of your cell or cells from
the Number Group Number Group under the Home Ribbon
Similar to what we saw in Access
AUTOFILLING
A powerful feature in Excel
Allows automatic filling of values based on data data patterns patterns
Drag the fill fill handle handle at the bottom right corner of a cell to
cover the range of interest then release
You could also use the fill button for more
control over filling data
(Home Ribbon Home Ribbon Editing Group Editing Group Fill Fill)
Series Series under Fill is very useful to fill a series
Autofilling Series (2)
Choose Autofilling by row or column
Type: Type:
Linear series
Multiplicative series (Growth)
Date
Step Value is the number
+ + or x x in the series
Stop Value is the value
where the series will stop
Autocomplete
Access will try to predict the text based
on your previous entries
Works for text and formulas
How to turn Auto Fill on or off?
1. Click the Microsoft Office Button
2. Click Excel Options
3. Click Advanced
4. Under Editing options, clear or select the Enable
AutoComplete for cell values check box
4/8/2013
10
Sort & Filter
Powerful feature in Excel that automatically sorts/filters cells
Select the cells to be sorted or filtered
Click the Sort&Filter Sort&Filter button on the Editing group Editing group of the
Home Ribbon
You could also access the Sort&Filter Sort&Filter button from Data
TabSort&Filter GroupSort or Filter)
1
2
3
Home
Tab
1
2
3
Home
Ribbon
For Text For Text For Numbers For Numbers
Sorting Options
Filtering versus Sorting? Filtering versus Sorting?
ATTACHING COMMENTS TO CELLS
A comment can be attached to a cell (Review Review Ribbon
Comments Comments Group Group, New Comment New Comment)
A cell with a comment is marked with a red red
triangle triangle on the top right corner
To see the comment place the cursor over the triangle
To edit a comment (ReviewRibbonComments Group
Edit Comment)
To clear a comment (ReviewRibbonComments Group
Delete Comment)
Alternatively right click on the cell to edit/delete comment
You can also hide/show your comments
4/8/2013
11
Split a Worksheet
We can split a worksheet into multiple resizable
panes for easier viewing
Click the Split button Split button on the View Ribbon
Notice the split in the screen manipulate each part
separately
Freeze Rows and Columns
You can select a particular portion of a worksheet to
stay static while you work on other parts of the
sheet Freeze Rows and Columns Freeze Rows and Columns
How can we do it?
Click the Freeze Panes Freeze Panes button on the View Ribbon
Either select a section to be frozen or click the defaults
of Top Row or Left Column
To unfreeze, click the Freeze Panes button
Click Unfreeze Unfreeze
Freeze Panes
4/8/2013
12
Formulas
Start with =, + or =, + or - -
Formulas may contain numeric values, arithmetic operators,
functions, and cell references/names
By default, the formula bar formula bar contains the formula
expression, while the cell display the result
To include a cell value in the formula, type its
reference/name or clicking on it
Arithmetic Order of Precedence
As in other programming environments, Excel follows the
following established order of precedence for arithmetic
operators:
Negation -
Exponentiation ^
Multiplication and division *, /
Addition or subtraction +, -
Use parentheses parentheses to overwrite the order of precedence.
Arithmetic Order of Precedence Arithmetic Order of Precedence
Relative and Absolute Cell References
By default Excel assumes that the cell reference is
relative relative
Consequently, when a cell is copied over to another
cell, all references will be adjusted in relation to
locations of the cells in the formula
A cell reference can be turned into an absolute one by
adding the $$ symbol
4/8/2013
13
Relative and Absolute Cell References
The $ symbol can be used to make the row, column or
both absolute absolute
=B3 Both are relative
=B$3 Row is absolute and column is relative
=$B3 Row is relative and column is absolute
=$B$3 Both are absolute
The type of reference can be conveniently modified
using the F4 F4 key
(or Function + F4 Function + F4 if F4 is already an assigned key)
Referencing to Other WS
Formulas can reference different Workbooks or
Sheets
When the source is open open (file is open):
=SUM([Budget.xlsx]Annual!C10:C25)
Sum the cells C10:C25 in the Annual WS from the Budget
file (WB)
When the source is NOT open NOT open:
=SUM('C:\Reports\[Budget.xlsx]Annual'!C10:C25)
Sum the cells C10:C25 in the Annual WS from the Budget
file (WB)
Can be used with cells in the existing WS:
=A10*Sheet2!B5
Value from Cell A10 of our current worksheet multiplied by
the value of Cell B5 from Sheet 2
Relative and Absolute Cell References
(Examples)
Copy from Copy to
Cell Formula Cell Formula
A6 =E5+F4 B7 =F6+G5
A6 =E$5+F4 B7 =F$5+G5
A6 =$E5+F4 B7 =$E6+G5
A6 =$E$5+F4 B7 =$E$5+G5
Formulas Ribbon
Groups:
Function
Library
Defined Names
Formula Auditing
Calculation
4/8/2013
14
The Function Library Group
Excel supports hundreds of functions, which are classified
into the following groups:
There are many ways to insert a function
-- Financial Financial -- Date & Time Date & Time
-- Mathematical Mathematical -- Trigonometric Trigonometric
-- Statistical Statistical -- Lookup & Reference Lookup & Reference
-- Text Text -- Logical Logical
-- Information Information -- User User--defined defined
Insert Functions (1)
Click the formulas tab
Insert Function Insert Function f f
x x
Button Button in function
library group
The Insert Function dialog box opens.
In the Search for a function box, type
a description description of what you want to do
1
2
3
Insert Functions (2)
Click the formulas tab
Choose from one of the Function Groups Function Groups, e.g. logical
Choose a function or if not visible , click on the Insert Function f
x
button
Insert Function dialog box appears
1
2
3
Insert Functions (3)
Click the formulas tab
Choose More Functions More Functions
Choose one of the categories (e.g. statistical) and then choose the function or
click on the Insert Function f
x
button Insert Function dialog box appears
1
2
3
4/8/2013
15
Insert Functions (4)
Click the Insert Function Insert Function Button Button on the
formula bar
The Insert Function dialog box opens
In the Search for a function box, type
a description of what you want to do.
Insert Functions (5)
Activate a cell and type = type =
Recent function Recent function names displayed
in the Name Box
Click the arrow to choose one
1
2
3
Text Formulas
Function Function Action Action
Left(text,[numb]) Returns leftmost characters from a text value
Right(text,[numb]) Returns rightmost characters from a text value
Len(text,[numb]) Returns the number of characters in a text string
Lower(text) Converts text to lowercase
Upper(text) Converts text to uppercase
Proper(text) Capitalizes the first letter in each word of a text
value
Mid(text, start, # of
characters)
Returns a specific number of characters from a
text string starting at the position you specify
Value(text) Converts a text argument to a number
Rep(text, times to
repeat)
Repeats text a given number of times
When To Use?
Landsat Satellite Data
Format Example: Format Example:
LXSPPPRRRYYYYDDDGSIVV
L = Landsat
X = Sensor
S= Satellite
PPP = WRS Path
RRR = WRS Row
YYYY = Year
DDD = Julian Day of Year
GSI = Ground Station Identifier
VV = Version
Sensor Examples: Sensor Examples:
LM10170391976031AAA01 (MSS)
LT40170361982320XXX08 (TM)
LE70160392004262EDC02 (ETM+)
Extract year Extract year
Extract day Extract day
Extract Location Extract Location
4/8/2013
16
Basic Math Functions (1)
Function Function Action Action
SQRT(num) Square root
ABS(num) Absolute value
SIN(num) Sine
COS(num) Cosine
TAN(num) Tangent
LN(num) Natural log
LOG10(num) Base 10 log
EXP(num) Raise e to num
PI() Returns value of pi
POWER(num,pwr) Raise num to pwr
SUM(range) Add numbers
Basic Math Functions (2)
Function Function Action Action
AVERAGE(range) Average
STDEV(range) Standard deviation
VAR(range) Variance
MAX(range) Maximum
MIN(range) Minimum
COUNT(range) How many in range
MEDIAN(range) Median
MODE(range) Mode
RAND() Returns random number (0-1)
ROUND(x,n) Round x to n decimal places
SIGN(x) Returns the sign of x
Logical Functions
Logical function are used for direct calculations
based on certain conditions
6 logical functions: AND AND, FALSE FALSE, IF IF, NOT NOT, OR OR &
TRUE TRUE
Examples:
=IF(C5<10,"low","high").
=IF(C5<10,(IF(D10<1, very low", "low")),"high")
CONDITION RESULT IF
CONDITION
IS TRUE
RESULT IF
CONDITION IS
FALSE
CONDITION IF CONDITION IS TRUEEVALUATE THIS IF
STATEMENTTO GETTHE RESULT
RESULT IF
CONDITION IS FALSE
NESTED NESTED
IF IF
Logical Functions
The AND AND function returns TRUE if all tested conditions
are true, and FALSE otherwise.
Example: =AND AND(C3=30, D3=9,E1=0)
The OR OR function returns TRUE if at least one condition is
true, and FALSE if all conditions are false
Example: =OR OR(C3=30, D3=9,E1=-1)
4/8/2013
17
If: Absolute Value Example
The number to be evaluated is entered into cell A1
The formula is entered into cell B1
Logical Functions Logical Functions
Comparison operators: Comparison operators:
Operator Operator Explanation Explanation
= Equal to
<> Not equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
Logical Functions
The NOT NOT function returns the opposite of its
logical statement.
Example: =NOT(AND(C3=30, D10=9,E1=0))
Combinations of AND, OR and NOT:
Combination Combination What does it mean? What does it mean?
NOT(AND(A,B)) TRUE if both are false
NOT(OR(A,B)) TRUE if neither is true
OR(AND(A,NOT(B)),
AND(B,NOT(A)))
True if only one is true
Logical Functions
IF statements is also used in other Excel functions:
SUMIF syntax:
SUMIF(range, criteria, [sum_range])
=SUMIF(A17:A25,"<30")
Sums all the values in the range A17:A25 that are less than 30
SUMIF(E17:E25,>145",D17:D25)
Sums the cells in the D17:D25 range, where corresponding cells
in E17:E25 have values > 145
COUNTIF(C2:C13, > &D1)
Count the # of cells where values > the value in D1
COUNTIF(C2:C13, > & AVERAGE(C2:C13))
What will this do?
4/8/2013
18
Logical Functions
Note that text criteria text criteria or any criteria any criteria that includes
logical or mathematical symbols must be enclosed in
double quotation marks (" ")
If the criteria is numeric, double quotation marks are not
required
The concatenation operator (&) is used to join the
symbols (>) with cell references
Calculate the monthly payments required for a
$900,000 $900,000 loan amortized over 30 30 years at a
constant interest of 5% 5%per annum
Example: Financial Functions
Can I buy a flat in Beirut? Can I buy a flat in Beirut?
SET UP THE PROBLEM
Select the Financial Category
Select the correct cell and
Choose the PMT function
4/8/2013
19
Select the PMT function
Choose the rate cell Choose the rate cell
Divide by 12 to convert into monthly rate Divide by 12 to convert into monthly rate
Select the PMT function
NPER is the # of payments NPER is the # of payments Years *12 Years *12
Select the PMT function
In PV (Present Value) Enter the loan amount In PV (Present Value) Enter the loan amount
Select the PMT function
In PV (Present Value) Enter the loan amount In PV (Present Value) Enter the loan amount
4/8/2013
20
The monthly payment is now calculated
Check the formula in the formula bar
Conclusion
No chance to buy a flat in Beirut except if I win the
lottery soon
Other Important Functions
Match Match: Looks for a value in a range
It returns the relative position of that item in the range
Syntax =MATCH(value, Range, Syntax =MATCH(value, Range, matchtype matchtype) )
Specifying the matchtype is optional. Defaults to 1
Specifying -1: Finds the smallest value that is greater than or
equal to value (the field has to be sorted in descending order)
Specifying 0: Finds the first value that is exactly equal to the
value
Specifying 1: Finds the largest value that is less than or equal
to value (the field has to be sorted in ascending order)
4/8/2013
21
INDEX
Index: Returns a value within a table or range
If you give it an array:
Syntax: = INDEX( = INDEX(array,row_num,column_num array,row_num,column_num) )
Example: Example:
=Index({1,2,3;3,5,6;7,8,9},2,3) =Index({1,2,3;3,5,6;7,8,9},2,3)
COUNT, COUNTIF, COUNTA
COUNT COUNT: Counts the number of cells that contain
numbers =COUNT(RANGE)
Arguments that are numbers, dates, or a text
representation of numbers
COUNTIF COUNTIF: Counts the number of cells that fulfills one
or more criteria = COUNTIF(range, criteria)
COUNTA COUNTA: Counts the number of cells that are not
empty in a specified range
It will count error values and empty text ("")
=COUNTA(RANGE)
Matrix Algebra in Excel Adding Two Matrices
To add two named 3 x 3 matrices A and B:
Highlight a blank 3 x 3 results area in the spreadsheet
If the results area is too small, you will get the wrong answer!
Type =A+B in the formula bar
Press the CTRL, SHIFT and ENTER keys simultaneously
Pressing enter will get you an error message or the wrong answer!
Look at the formula: You should see braces braces surrounding the
array formula Matrix Operation Matrix Operation
4/8/2013
22
Matrix Transpose
Suppose D is a 5 x 4 matrix
The transpose of D is D, which is 4 x 5 matrix
Select the 4 x 5 results area
Type =TRANSPOSE(D) in the formula bar
Press CTRL, SHIFT, ENTER
You should get the transpose of D
Multiply Matrix by a Scalar
Suppose D is a 5 x 4 matrix
5xD is also a 5 x 4 matrix
Select a 5 x 4 results area
Type = 5*D = 5*D in the formula bar
Press CTRL, SHIFT, ENTER
You should get the matrix 5xD
Matrix Multiplication
Suppose E and F are 3 x 2 and 2 x 3 matrices
Then EF is 3 x 3 and FE is 2 x 2
Select a blank 3 x 3 area for the result EF
Type = =MMULT(E,F) MMULT(E,F) in the formula bar
Press CTRL, SHIFT, ENTER to generate EF
=MMULT(F,E) for the result FE
Matrix Inverse
Suppose B is a square 3 x3 matrix
Select a 3 x 3 area for the inverse of B
Type =MINVERSE(B) =MINVERSE(B) in the formula bar
Press CRTL, SHIFT, ENTER
What will happen when B is singular?
If B is singular (non-invertible), you will get an error
message
4/8/2013
23
Matrix Determinant
Suppose A is a square matrix
The size of the determinant of A is?
det(A) is a scalar
Select a single cell, type = MDETERM(A) = MDETERM(A) in the
formula area
Press CTRL, SHIFT, ENTER
If A is singular, then det(A) should be what?
Now you should be able to
solve systems of linear
equations in Excel
Formula Auditing Tools in
Excel
To use the Auditing Tools in Excel click on the formula you
wish to audit
Go to the Formulas tab in the Office Ribbon Office Ribbon
Trace Precedents Trace Precedents tool for a selected cell with a formula:
Arrows Arrows will appear pointing to the cells included in formula
This helps you determine where the values that make up
your formula come from
Formula Auditing Tools in
Excel
To use the Auditing Tools in Excel click on the formula
you wish to audit
Go to the Formulas tab in the Office Ribbon Office Ribbon
Trace Dependents Trace Dependents tool tells you which cells rely or are
dependent on the selected cell
Great tool to use before you delete a cell!
4/8/2013
24
Formula Auditing Tools in
Excel
Show Formulas button Show Formulas button: Cells containing formulas will
display formulas
Error Checking button Error Checking button: Make sure that the formulas you
are using are all correct
Evaluate Formula tool Evaluate Formula tool: Evaluates the formula step-by-
step
Click on the cell containing the formula you want to evaluate
Click on the Evaluate Formula button
Options to Evaluate the formula or Stepping In a formula
Error Messages
Message Message Explanation Explanation
#NUM! #NUM! Number error, e.g. SQRT(-10).
#DIV/0! #DIV/0! Dividing by zero
#N/A #N/A Missing data or wrong value for lookup function
#NULL! #NULL! Specified cells do not intersect
#REF! #REF! Invalid reference/cell name
Circular Error Circular Error Cell referring to itself
#NAME? #NAME? Undefined variable or function
#VALUE #VALUE Result of a mathematical operation on cells that contain both text
and values
Excel issues an error message and suggests a correction if the
formula expression is invalid
Integration in Excel
No built-in integration function in Excel
Will need to use numerical integration:
Rectangle Method
Trapezoid Method Trapezoid Method
Simpsons Rule Method
Gauss Quadrature
Example: Trapezoidal rule in Excel
Suppose we have an object that is moving with a
velocity that is described by this equation:
v = ( v = (- -0.011t 0.011t
33
- - 0.2t 0.2t
22
+ 2.4t + 2) + 2.4t + 2) m/sec
The object starts at - -18 meters 18 meters initially
Calculate the objects position after 10 seconds
Analytical solution is easy:
Position is the indefinite integral of the velocity
4/8/2013
25
Trapezoidal Rule
http://www.mpia-hd.mpg.de/~mordasini/UKNUM/Lecture_05.pdf
Multiple segment trapezoidal rule will enhance accuracy
Trapezoidal rule in Excel
1. First set up the problem
2. Calculate velocity over a range of t
3. Use the multiple segment trapezoidal rule multiple segment trapezoidal rule:
A. Get the values of v for every t
B. Calculate the sum of the 2 velocities
C. Calculate Delta t
D. Calculate the trapezoid area
E. Make sure to add the previous area to it
Differentiation in Excel
No built-in differentiation function in Excel
Will need to use numerical differentiation:
Simple difference method Simple difference method:
Forward (y
1
-y
0
)/h
Center (y
1
-y
-1
)/2h
Backward (y
0
-y
-1
)/h
Calculate the steps (x)
Get the slope (y
2
-y
1
)/(x)
Other methods (5-point stencil, differential quadrature)
VLOOKUP & HLOOKUP
VV = For Vertical/column lookup
H H = Horizontal/row lookup
Lookup functions are designed to
retrieve information from tabular
data based on certain specifications or
conditions conditions
4/8/2013
26
HOW TO USE IT?
Think of the 3 Ws: Think of the 3 Ws:
What What is your lookup value?
Where Where to look up?
Which Which column holds your results?
VLOOKUP
Using VLOOKUP VLOOKUP is similar to looking up
a persons name in a telephone directory
to get his/her telephone number
VLOOKUP VLOOKUP looks at a value in one
column, and finds its corresponding
value on the same row same row in another another
column column
Similar to building a very simple query in
Access Access
VLOOKUP: Syntax
=VLOOKUP VLOOKUP(lookup_value, table_array, col_index_number,
not_exact_match)
lookup_value: The value that the function will look for in
the left most column left most column
table_array: The table that the function will look through
col_index_number: The column number from which the
function should return the value
not_exact_match: Can be either True or False
True = find the next largest value that is less than the
lookup_value (default)
False = find exact match
VLOOKUP: Example
Question: find the price
for item with ID #12
CC E E DD
50 50
51 51
53 53
52 52
=VLOOKUP(12, C50:E53 ,22, FALSE FALSE)
Answer = 14.33
4/8/2013
27
Common Mistakes with
Vlookup
You need to sort your result column sort your result column in ascending order
when using Exact=FALSE
Excel does not interpolate does not interpolate values values
The # of the result column is from the beginning of the beginning of the
range range and not from the beginning of the sheet
The lookup field has to be the leftmost field leftmost field
HLOOKUP: SIMILAR BUT FOR ROWS
=HLOOKUP (12, A1:E3, 2, False) =HLOOKUP (12, A1:E3, 2, False) Look in 2
nd
row for the
value corresponding to 12 in top row, and look for exact match
114.33 4.33
=HLOOKUP (10, A1:E3, 2, False) =HLOOKUP (10, A1:E3, 2, False) Look in the 2
nd
row for the
value corresponding to 10 in top row, and look for exact match
to 10 #N/A #N/A
=HLOOKUP (50, A1:E3, 3, True) =HLOOKUP (50, A1:E3, 3, True) Look in the 3
rd
row for the
value corresponding to 50 in top row. No 50 but not exact
Match with the largest value in top row that is less than the
lookup value of 52 88
A Note About Lookup Tables
Lookup tables will not interpolate values! not interpolate values!
When looking up a numerical value:
TRUE TRUE option is selected (default) an approximate match
The value searched for is rounded down rounded down to the next
tabulated value!
PIVOT TABLE
Provides a powerful tool for summarizing large amounts of
tabular data
A pivot table classifies numeric data in a list based on other
fields in the list
General purpose:
1. Quickly summarize data from a worksheet
2. Calculate totals, averages, counts, etc. based on any numeric
fields in your table
3. Generate charts from your pivot tables
Similar to Crosstab in Access Similar to Crosstab in Access
4/8/2013
28
Before You Begin: A Note About Pivot Tables
Data should be arranged in a list:
Columns Columns represent fields
Rows Rows represent a record of related data
First row First row = = Column label Column label
Each column should contain 11 type of data
For example, text in 1 column and numeric values in another
When you create a PivotTable, each column of source data
becomes a field that you can use in the report
Should have no incomplete records in your columns
Its also best if there are no empty rows
Be careful of empty cells, are they blank or are they zeros?
Pivot Table (I)
1. When the data is ready, click anywhere in a sheet
2. On the Insert Ribbon Insert Ribbon, go to Tables group Tables group, click PivotTable PivotTable
3. The Create PivotTable Create PivotTable dialog box opens
4. Select the range that you want to work with
5. Select where you want the Pivot Table to be placed (default is
new sheet)
Pivot Table (II)
After you close the Create PivotTable Create PivotTable dialog box you
should see:
1. On one side the Layout Area Layout Area ready for the PivotTable report
2. On the other side the PivotTable Field List PivotTable Field List
Shows the column titles from the source data (each column title is a field)
Pivot Table (III)
Drag & drop fields to build your pivot table
4 areas to place fields:
1. 1. Report Filter Report Filter
2. 2. Column Labels Column Labels
3. 3. Row Labels Row Labels
4. 4. Values Values
No need to use ALL ALL your your fields!
No need to fill ALL ALL 4 areas!
1 1 22
33 4 4
4/8/2013
29
Pivot Table (IV)
If you click outside the layout area of a PivotTable report
the PivotTable Field List PivotTable Field List goes away
To get the field list back, click inside the PivotTable layout
area or report
You can SORT SORT the data only by the fields in the Row Row
Labels Labels
Unlike Access you can have multiple column labels multiple column labels
Note that you may create a PivotTable based on an
external data source
Pivot Table (V)
A PivotTable report with more than one row field has:
One Inner Row Inner Row field (closest to the data area)
and other Outer Row Outer Row fields
Items in the outermost outermost row field are displayed
once
Items in the rest of the row fields are repeated as
necessary
Pivot Table (VI)
A PivotTable will always add:
A column total A column total
A row total A row total (if you have multiple columns)
Cell Referencing to a PivotTable
GETPIVOTDATA GETPIVOTDATA function appears automatically when you
try to reference a cell inside the Pivot Table
If you remove any of the fields referenced in the
GETPIVOTDATA formula from the report, the formula returns
#REF!
Name of the Value Label Name of the Value Label
Beginning of Table Beginning of Table
Name of the Row Label Name of the Row Label
Row Label Row Label
4/8/2013
30
Cell Referencing to a PivotTable
Name of the Value Label Name of the Value Label
Beginning of Table Beginning of Table
Name of the Row Label Name of the Row Label
Row Name Row Name
GOAL SEEK
Goal Seek Goal Seek allows us to conduct what what- -if analysis if analysis
Use Goal Seek Goal Seek when you know the desired result desired result of
a single formula but not the input value needed to get
the result
The command uses iterations iterations to obtain the desired
results
Goal Seek Goal Seek uses a process of changing the values in
cells to see how those changes affect the outcome of
formulas on the worksheet
Goal Seek: How To?
Go to the Data Ribbon Data Ribbon
Go to the Data Tools Data Tools group
Click What What- -If Analysis If Analysis
Click Goal Seek Goal Seek
Will get the Goal Seek window:
Set Cell: The cell that you want it to achieve a target
To Value: The value that you want to reach
By Changing Cell: What cell needs to change
Goal Seek
4/8/2013
31
Goal Seek: Troubleshooting
Make sure the Set cell reference Set cell reference is to a cell that
contains a formula, function, or cell reference formula, function, or cell reference
Make sure the To value cell To value cell value is a reasonable
value
Make sure the By changing cell reference By changing cell reference is not a
formula, function, or a cell reference
Make sure there is a link by formulas between the
two cells you entered in the Goal Seek Goal Seek
However complicated the link might be, they MUST MUST
BE BE related
Root-Finding with Excel
Can we use Goal Seek to find the root of an
equation?
Yes! Yes!
Identify one cell to hold the value of the independent
variable (let us call it x)
In another cell put the formula for f(x)
Guess a plausible estimate of a root and input it in
the first cell
Select the Goal Seek Goal Seek function
Set the target value to 00
Example
What are the roots of:
Excel Shortcomings
Excel will find one of the roots one of the roots of the equation
depending on the starting value
Use extreme values as your guesses (eg 100000
and 100000) to find the largest and smallest roots
Plot the function and use approximate roots as your
initial guess
4/8/2013
32
Optimizing in Excel: Solver
First need to add Solver to Excel:
Check to see if you have it under the Data Ribbon Data Ribbon
If not then:
Go to the Microsoft Button Microsoft Button
Click on Excel Options Excel Options
Go to the Add Add- -Ins Tab Ins Tab
In the Manage Manage box, select Excel Add Excel Add- -ins ins
In the Add Add- -Ins Ins available box, select the Solver Add Solver Add- -in in
check box, and then click OK OK
Adding Solver
Solver in Excel
You should see the Solver Solver under the Data Data
Ribbon Ribbon, Analysis Group Analysis Group
Optimizing in Excel: Solver
An optimization model in Excel has 3 parts:
The target cell The target cell
The changing cells The changing cells
The constraints The constraints
Solver helps find optimal values in one or more
cells, called the target cell(s) target cell(s), by changing a changing a
group of cells group of cells to find an optimal value subject to
the constraints constraints that you set
4/8/2013
33
Target Cells
The target cell represents the objective objective or goal goal
Usually we want to either minimize minimize or maximize maximize the
target cell
Maximize or Maximize or minimize minimize Target cell Target cell
Maximize Maximize Monthly profit Monthly profit
Minimize Distribution costs
Maximize Net present value contributed by selected projects
Minimize
Difference between scores predicted by ratings and
actual scores
Minimize Riskiness of portfolio
Changing Cells
Changing cells are the spreadsheet cells that we want
to change change or adjust adjust to optimize the solution in the
target cell
Changing cells Changing cells
Amount of each product produced during the month Amount of each product produced during the month
Amount produced at each plant each month that is shipped
to each customer
Team ratings
Fraction of money invested in each asset class
Constraints
Constraints are restrictions restrictions we place on the changing
cells to constrain our solution
They need to be acheived
Constraints Constraints
Product mix uses no more resources than are available
Do not produce more of a product than can be sold Do not produce more of a product than can be sold
Do not ship more units each month from a plant than plant capacity
Prices can't be too far out of line with competitors prices
Projects selected can't use more money or skilled programmers than
are available
None None
Obtain an expected return of at least 10 percent on our investments
Example 1: Building Apartments
Type 1: Type 1:
2 truck loads of concrete
4 cable rolls
4 dozens of Fe beams
6 man months
2 pipe loads
Profit per unit is $95,000
Type 2: Type 2:
1 truck loads of concrete
2 cable rolls
2 dozens of Iron beams
2 man months
1 pipe loads
Profit per unit is $45,000
Type 3: Type 3:
1 truck loads of concrete
1 cable rolls
1 dozens of Iron beams
1 man months
1 pipe loads
Profit per unit is $22,000
You can build 3 types of apartments: You can build 3 types of apartments:
Goal: Maximize Profit Goal: Maximize Profit
4/8/2013
34
Constraints Constraints on Building
1. Can not exceed inventory of products
2. Need to build at least 5 units at least 5 units of each type
3. Can not build more than 500 units of any type 500 units of any type
4. The number of units in each category has to be
an integer and positive integer and positive
Example 2: Chemical
Procurement
A company manufactures 3 types of chemicals 3 types of chemicals
It has a contract to supply its customers with the
following amounts of the three chemicals:
Chemical 1 Chemical 2 Chemical 3
Contracted Sales (lbs) 2000 3500 1800
Adapted from:
www.faculty.haas.berkeley.edu/andy/blockhandouts/Opt%20I.ppt
Chemical Procurement
Production is limited by the availability of processing
time in the two chemical ovens two chemical ovens
Each chemical must be processed first in Oven 1
and then in Oven 2
Hours of processing time processing time available for each oven
and the processing time required in each oven for
each chemical is:
Reactor Processing Times Reactor Processing Times
(hrs per lb) (hrs per lb)
Chemical 1 Chemical 2 Chemical 3
Reactor Reactor
Availabilities Availabilities
(hrs) (hrs)
Oven 1
0.05 0.04 0.01 200 200
Oven 2
0.02 0.06 0.03 150 150
4/8/2013
35
Chemical Procurement
Because of the limited availability of Oven
processing time, there is insufficient capacity insufficient capacity
to meet the demand with in-house production
Must purchase some chemicals from vendors
The following table provides each chemicals in in- -
house house production cost and outside outside purchase
cost:
Chemical 1 Chemical 1 Chemical 2 Chemical 2 Chemical 3 Chemical 3
In In- -house Production house Production Cost ($/lb) Cost ($/lb) $2.50 $1.75 $2.90
Outside Purchase Outside Purchase Cost ($/lb) Cost ($/lb) $2.80 $2.50 $3.25
QUESTION
Which chemicals should we buy from the
outside suppliers?
How much of each chemical should we produce
in-house?
Goal: Minimize Cost Goal: Minimize Cost
Constraints Constraints
Need to fullfill the customers orders
Need the cheapest combination of in-house
production and outside purchases
Can not exceed the amount of operational time in the
2 ovens
Amounts produced and bought need to be > 0
Must decide how much how much of each chemical to
produce in produce in- -house house (i.e., make) and how much
of each chemical to purchase outside purchase outside (i.e.,buy)
4/8/2013
36
Solver Options: Accuracy
Max time: Max time: Limits the time taken by
the solution process
Iterations: Iterations: Limits the number of
interim calculations
Precision: Precision: Controls the precision of
solutions
Tolerance: Tolerance: The % by which the
target cell can differ from the true
optimal value
Convergence: Convergence: When the relative
change in the target cell value is less
than the selected number for the
last 5 iterations Solver stops
Must be indicated by a fractional
between 0 and 1
Solver Options: Assumptions
Radio buttons Radio buttons to
choose from depending
on your problem
E.g Choose linear model
if all relationships in the
model are linear and
you want to solve a
linear optimization
problem
Solver Options: Estimates
Specifies the approach
that is used to obtain
initial estimates of the
basic variables
Choose quadratic when
the problem is non-
linear
Solver Options: Derivatives
Specifies the
differencing that is used
to estimate derivatives
Forward
Central
4/8/2013
37
Solver Options: Search
Specifies the algorithm
used at each iteration to
determine the search
Newton (More memory
less iterations)
Conjugate (More
iterations less memory)
Graphing in Excel
A Picture is Worth a A Picture is Worth a
Thousand Words Thousand Words
First quoted in 1911
Excel Chart Types
There are 11 11 major chart types in Microsoft Excel
Each has its own set of chart subtypes subtypes
4/8/2013
38
Creating a Basic Graph in
Excel
4 clicks 4 clicks between you and a graph:
1. Use the mouse to select the data select the data
To select noncontiguous data in a spreadsheet, hold down
Ctrl Ctrl button while dragging mouse to select cells
2. Go to the Insert Ribbon Insert Ribbon
3. Go to the Charts Group Charts Group
4. Click on the chart type chart type you want
Excel will generate the graph for you
It still needs to be Formatted! Formatted!
Scatter Versus Line Graphs
Scatter Versus Line Graphs
They may look very similar; but but
Big difference in the way each of these chart types plots
data along the x x- -axis: axis:
Scatter chart displays numerical values along the
horizontal and the vertical axis
A scatter chart will not display categories on horizontal axis
Line chart distributes category or time interval data
evenly evenly along a horizontal axis (even if numeric)
Know exactly what you want!
3 D Plots
Surface charts generate three dimensional surface three dimensional surface
Colors and patterns in a Surface chart indicate areas
that contain the same range of values range of values
Need to organize the data in your worksheet:
4/8/2013
39
Excel: Surface Chart Types
4 Major types 4 Major types
Creating a Surface Chart
1. Select the data you want to display in a
Surface or Contour chart
2. On the Insert menu, click Chart
3. In the Chart type box, click Surface
4. Under Chart sub-type, click the type you
want to use
5. Click Next
Surface Plots Editing a Chart in Excel
When a chart is created and/or selected, the Chart Chart
Tools Tools appear in the Excel Ribbon
Design Tab Design Tab
Layout Tab Layout Tab
Format Tab Format Tab
4/8/2013
40
Chart Tools
Within the Design tab Design tab you can control the chart type, data, layout,
styles, and location
Within the Layout tab Layout tab you can control current selection, inserting
pictures, shapes and text boxes, labels, axes, background, and analysis
Within the Format tab Format tab you can modify current selection, shape styles,
word styles and size of the chart
Changing a Chart Type
Select your graph that you want to change
Click on the Design tab Design tab
Click on Change Chart Type Change Chart Type
Select a new graph from the Chart Type Chart Type dialog box that
appears
Click OK OK
Adding Chart Elements
There are 15 chart elements 15 chart elements that can be added to a chart in
Excel
Adding a Chart Title Adding a Chart Title
Adding Axes Adding Axes
Adding a Legend Adding a Legend
Adding Data Labels Adding Data Labels
Adding a Data Table Adding a Data Table
Adding Gridlines Adding Gridlines
Adding Chart Elements
There are 15 chart elements 15 chart elements that can be added to a chart
Excel has predefined chart layouts located in the Design Design
tab tab that include many of these elements already added
4/8/2013
41
Adding Chart Elements
There are 15 chart elements 15 chart elements that can be added to a chart
Excel has predefined chart layouts located in the Design Design
tab tab that include many of these elements already added
You can manually manually add individual chart elements to your graph
by using the options located in the Layout tab Layout tab
Click on the Layout tab Layout tab and locate the appropriate Label Label
group: group:
Click on down arrow on Chart Title button Chart Title button (select a title layout)
Click on down arrow for the Axis Titles button Axis Titles button (add title to chart axis)
Click on down arrow for the Legend button Legend button (add legend)
Click on down arrow for the Data Labels button Data Labels button (add values to graph)
Click on down arrow for the Data Table button Data Table button (add data as table)
Check the different options + Check the different options +
MoreOptions MoreOptions
Formatting Axes
Select your charts X or Y axis
Click on the Layout tab Layout tab
Click the Format Selection Format Selection
button under Current Selection
group
Under Axis Options you can make
many changes:
Min-Max
Log scale
Tick marks
Change color of axis line
You can also access it from the
Axes Group Axes Group under Layout Layout
Axis: Primary and Secondary
4/8/2013
42
Adding a Second Axis
You can plot one or more data series on a secondary axis secondary axis
Good when you have 2 series that have a wide range or
are different in type and you want them on the same plot
How to do it?
Add the data series to your plot
Select the data series that you want to have on a secondary
axis
Go to the Format Format menu
Click the Selected Data Series Selected Data Series icon under the Current Current
Selection group Selection group
Under the Axis Axis tab, click Secondary Axis Secondary Axis
Adding a Second Axis
One Chart 2 Chart Types
You can plot one or more data series in the same chart
but with different chart types
How to do it?
Click the data series that you want to change its type
Go to the Design Design menu
Click the Change Chart Type Change Chart Type icon under the Type Type group group
Select the new type
Press OK OK
Note that the 2 types have to be compatible compatible
One Chart 2 Chart Types
4/8/2013
43
Adding a Trend Line and
Regression Equation
You can add a trendline to any data series (given a chart type)
Trendlines are regression models regression models that Excel adds to your
graph
Moving average smoothes out fluctuations in data
Six different trends available:
Linear trendlines
Logarithmic trendlines
Polynomial trendlines
Power trendlines
Exponential trendlines
Moving average trendlines
Trend Lines
Linear Linear trendlines trendlines (best-fit straight line)
Logarithmic Logarithmic trendlines trendlines (best-fit curved line when
the rate of change in the data increases or decreases quickly
and then levels out)
Polynomial Polynomial trendlines trendlines (best curved line, n
th
degree)
Power Power trendlines trendlines (curved line when increase is at a
specific rate)
Exponential Exponential trendlines trendlines (values rise or fall at
constantly increasing rates)
Moving average Moving average trendlines trendlines
Type Type Equation Equation
Linear
Logarithmic (semi)
Polynomial
Power
Exponential
Moving average
Trend Lines
Add a Trendline and Its
Equation
Click anywhere in the chart
Select the series
Right click and select Add trendline
Choose the appropriate appropriate trendline trendline
Select any appropriate options:
Forecast
Hindcast
Intercept
Choose to display R R
22
and the equation of the line
4/8/2013
44
Reminder: What is R
2
?
It is the Coefficient of determination Coefficient of determination
Between 0 and 1 0 and 1
Describe how well a regression line fits a set of data
Trendline: Warnings
If you add a trendline to a line, column, area, or bar
chart, the trendline is calculated based on the
assumption that the x values are 1, 2, 3, 4, 5, 6, etc
This assumption is made even if the x-values are
numeric or text!
To base a trendline on numeric x values, you should use an
xy xy (scatter) chart (scatter) chart
If you add a moving average moving average to an xy (scatter) chart:
Moving average is based on the order of the x values
plotted in the chart
To get the result that you want, you have to make sure make sure
that that the x values are ordered as you want before you add
the moving average
Printing in Excel (1)
Click the Page Layout Ribbon to change page settings:
Set the individual Margins
Create Headers and Footers
Add Background
Set print area: Set print area:
By default, Excel prints the entire spreadsheet
A print area allows you to specify only a portion of the
spreadsheet to be printed
Click Print Titles Print Titles to access advanced Page Setup setting:
Rows and columns repeat on multiple pages
4/8/2013
45
Printing in Excel (2)
You can insert a Break:
Select a cell belowwhere you want the break to appear
Select the Breaks Breaks command
Select Insert Break
To print a graph by itself:
Select the graph
Click Ctrl+P to open the Print
dialog box
Make sure that the Selected Chart option button is selected
in the Print What section
Importing to Excel
Excel accepts two commonly used text file formats:
Delimited text files (.txt .txt), in which the TAB character
separates each field of text (ASCII)
Comma separated files ..csv csv files
You can also change the separator character used
For text files other than .csv you will get the Text Import Text Import
Wizard Wizard
You can import or export up to 1,048,576 rows and 16,384
columns
.dbf (dBase III and IV) can be opened in Excel, but you
cannot save an Excel file to dBase format
Exporting from Excel
You can save Excel data in formats other than .xls or .xlsx:
Use the data in other programs or applications
You can easily save Excel data into many formats:
..csv csv
.txt .txt
Note that formatting, graphics, and other objects will be
lost when saving data in a .txt or .csv file
You save the WS not the WB! You save the WS not the WB!
Matlab and R have capabailities to read Excel files
Often better to use .csv files
Lock Cells
Excel provides options to protect a workbook either by
protecting specific cells or the whole worksheet
Locking a Cell
1. Lock a cell (Home tab Format Lock Cell)
2. Prevents cells from being changed
1
2
3
Home
Tab
4/8/2013
46
Protect Sheet
Protect Cells and Sheets
a.Home Format Protect Sheet
b.Review TabChangesProtect
Sheet
Questions? Questions?

You might also like