excel: how to
TRANSCRIPT
-
8/11/2019 Excel: How To
1/46
Ibrahim AlameddineIbrahim Alameddine
Microsoft Office Excel 2007 Excel is part of the Microsoft Office suite and many
others like Word, PPT, etc.
Excel helps you analyzeanalyze informationinformation for informeddecisions by providing a comprehensive set of tools to
createcreate tablestables && charts,charts, writingwriting formulasformulas, etc.
DocumentWindow/
Workbook
Title Bar
RibbonRibbon
-
8/11/2019 Excel: How To
2/46
Excel WorkbooksAn Excel document is referred to as a workbookworkbook (WB)(WB) and is
made of one or more worksheet(s)worksheet(s) (WS)(WS) or what we oftencall spreadsheetsspreadsheets
A WS resembles a table with columns labeled by lettersletters androws by numbersnumbers (e.g. A1)
Users can add, delete, rename, copy and move worksheets
Only one WS can be activeactive 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 WSExcel has a limit to the size of its WS
Maximum worksheet size:
65,536 Rows65,536 Rows
256 Columns256 Columns (A, AA, etc)
active sheet
non-active sheets scroll bars
row 1111
c
o
l
u
m
n
JJ
Excel Worksheet: Cells
Worksheets are made of cellscells, each identified byintersectingintersecting columncolumn andand rowrow, e.g. C3, G10, etc
A cell can be activated by clicking on it
The name of the active cell is shown in the namebox
Clicking on any other cell will cause the currentlyactive to be deactivated
-
8/11/2019 Excel: How To
3/46
active cell
nonactive cell
name box
formula barD6
F12
Range
Specify a range namein the Name Box
Groups:
Clipboard
Font
Alignment
Number
Styles
Cells
Editing
Home Ribbon
-
8/11/2019 Excel: How To
4/46
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 TypesAlignment Types:Horizontal alignmentVertical alignmentText DirectionText DirectionWrap textWrap textMerge cellsMerge cells
Click the cell or cells you want to align Click on the options within the Alignment group on the HomeHome
RibbonRibbon There are several options for alignment of cell contents:
Top AlignTop Align: Aligns text to the top of the cell Middle AlignMiddle Align: Aligns text between the top and bottom of the cell Bottom AlignBottom Align: Aligns text to the bottom of the cell Align Text LeftAlign Text Left: Aligns text to the left of the cell CenterCenter: Centers the text from left to right in the cell Align Text RightAlign Text Right: Aligns text to the right of the cell
OrientationOrientation: Rotate the text diagonally or vertically Decrease IndentDecrease Indent: Decreases the indent between the left border
and the text Increase IndentIncrease 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 theAlignment groupAlignment groupof the Home RibbonHome Ribbon
4 choices for merging cells:4 choices for merging cells: Merge & CenterMerge & Center: Combines the cells and centers the contents in the
new, larger cell
Merge AcrossMerge Across: Combines the cells across columns without centeringdata
Merge CellsMerge Cells: Combines the cells in a range without centering
Unmerge CellsUnmerge Cells: Splits the cell that has been merged
Merged cell will only retain theretain thedata of the left celldata of the left cell(Merge before inputting data)
-
8/11/2019 Excel: How To
5/46
Wrapping Text
Allows you to overcome overflowing content in yourcells
Modify Text FontsTo modify a text font:1. Select the cell or cells that you would like the font applied2. On the FontFont group on the Home RibbonHome Ribbon, choose the font
type, size, bold, italics, underline, or color
Add Borders to Cells
To add borders manually: Click the BordersBorders drop
down menu on the FontGroup of the HomeRibbon
Choose the appropriate
border More options Click
More Borders
1
2
3
Add Colors/Fill to CellsTo apply colors manually:
Click Fill drop down menu on Font GroupFont Group of Home RibbonHome Ribbon
Choose the appropriate color1
2
3
-
8/11/2019 Excel: How To
6/46
Apply Borders & Colors using Styles
To apply borders and colors using styles:1. Click Cell StylesCell Styles on the Home RibbonHome Ribbon2. Choose a style or click New Cell StyleNew Cell Style
12
3
Conditional Formatting It is hard to read and interpret data by scanning rows
and rows of information ColorsColors cancan helphelp
Use conditional formatting to make data stand out Help analyze dataanalyze data and identify patterns & trendsidentify patterns & trends
Apply barsApply bars Length of barValue
Apply colorsApply colors ColorValue
Apply symbolsApply symbols SymbolValue
You can apply multiple conditional formattingmultiple conditional formatting in a single
WS
Conditional Formatting(Setting Rules)
Excel Built in rulesExcel 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 areAll rules areautomatically updatableautomatically updatable
1
2
-
8/11/2019 Excel: How To
7/46
Conditional Formatting & Format asTable
Conditionally format cellsConditionally format cells Format cells as styled tableFormat cells as styled table
Click Conditional Formattingon the Home Ribbon
Choose a rule, e.g. highlighta cell if Number
-
8/11/2019 Excel: How To
8/46
Hiding Move/Copy A SheetTo 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 SheetsOrganize Sheets
Click Move or Copy Sheet
To make a copy: In the Move or Copy dialog box, select theCreate a CopyCreate a Copy check box
The worksheet is duplicated in the workbook, and the sheetname 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
Rename A Sheet Right click the sheet and choose rename
Under the Home Ribbon, in the Cells Group:
Click FormatFormat
Under Organize SheetsOrganize Sheets
Click Move or Copy Sheet
-
8/11/2019 Excel: How To
9/46
Number FormatYou can define the format typeformat type of your cell or cells from
the Number GroupNumber Group under the Home Ribbon
Similar to what we saw in Access
AUTOFILLINGA powerful feature in Excel
Allows automatic filling of values based on datadata patternspatterns
Drag the fillfill handlehandle 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 RibbonHome Ribbon Editing GroupEditing Group FillFill)
SeriesSeries 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++ orxx in the series
Stop Value is the valuewhere the series will stop
Autocomplete
Access will try to predict the text basedon 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 Options3. ClickAdvanced
4. Under Editing options, clear or select the EnableAutoComplete for cell values check box
-
8/11/2019 Excel: How To
10/46
Sort & Filter Powerful feature in Excel that automatically sorts/filters cells
Select the cells to be sorted or filtered
Click the Sort&FilterSort&Filter button on the Editing groupEditing group of theHome Ribbon
You could also access the Sort&FilterSort&Filter button from DataTabSort&Filter GroupSort or Filter)
1 2
3
1 2
3
Sorting Options
Filtering versus Sorting?Filtering versus Sorting?
ATTACHING COMMENTS TO CELLS
A comment can be attached to a cell (ReviewReview RibbonCommentsComments GroupGroup, New CommentNew Comment)
A cell with a comment is marked with a redredtriangletriangle on the top right corner
To see the comment place the cursor over the triangle
To edit a comment (Review Ribbon Comments Group Edit Comment)
To clear a comment (Review Ribbon Comments Group Delete Comment)
Alternatively right click on the cell to edit/delete comment
You can also hide/show your comments
-
8/11/2019 Excel: How To
11/46
Split a Worksheet
We can split a worksheet into multiple resizablepanes for easier viewing
Click the Split buttonSplit button on the View Ribbon
Notice the split in the screen manipulate each partseparately
Freeze Rows and Columns
You can select a particular portion of a worksheet tostay static while you work on other parts of thesheet Freeze Rows and ColumnsFreeze Rows and Columns
How can we do it?
Click the Freeze PanesFreeze Panes button on the View Ribbon
Either select a section to be frozen or click the defaultsof Top Row or Left Column
To unfreeze, click the Freeze Panes button
Click UnfreezeUnfreeze
Freeze Panes
-
8/11/2019 Excel: How To
12/46
Formulas Start with =, + or=, + or --
Formulas may contain numeric values, arithmetic operators,functions, and cell references/names
By default, the formula barformula bar contains the formulaexpression, while the cell display the result
To include a cell value in the formula, type itsreference/name or clicking on it
Arithmetic Order of Precedence
As in other programming environments, Excel follows thefollowing established order of precedence for arithmeticoperators:
Negation -
Exponentiation ^
Multiplication and division *, /
Addition or subtraction +, -
Use parenthesesparentheses to overwrite the order of precedence.
Arithmetic Order of PrecedenceArithmetic Order of Precedence Relative and Absolute Cell References
By default Excel assumes that the cell reference isrelativerelative
Consequently, when a cell is copied over to anothercell, all references will be adjusted in relation tolocations of the cells in the formula
A cell reference can be turned into an absolute one byadding the $$ symbol
-
8/11/2019 Excel: How To
13/46
Relative and Absolute Cell References
The $ symbol can be used to make the row, column orboth absoluteabsolute
=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 modifiedusing the F4F4 key
(or Function + F4Function + F4 if F4 is already an assigned key)
Referencing to Other WS Formulas can reference different Workbooks orSheets When the source is openopen (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 openNOT 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!B5Value 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 RibbonGroups:
Function
Library
Defined Names
Formula Auditing
Calculation
-
8/11/2019 Excel: How To
14/46
The Function Library Group Excel supports hundreds of functions, which are classified
into the following groups:
There are many ways to insert a function
-- FinancialFinancial -- Date & TimeDate & Time
-- MathematicalMathematical -- TrigonometricTrigonometric
-- StatisticalStatistical -- Lookup & ReferenceLookup & Reference
-- TextText -- LogicalLogical
-- InformationInformation -- UserUser--defineddefined
Insert Functions (1)
Click the formulas tab
Insert FunctionInsert Function ffxx ButtonButton in functionlibrary group
The Insert Function dialog box opens.
In the Search for a function box, typea descriptiondescription of what you want to do
1
2
3
Insert Functions (2)
Click the formulas tab
Choose from one of the Function GroupsFunction Groups, e.g. logical
Choose a function or if not visible , click on the Insert Function fx button
Insert Function dialog box appears
1
2
3
Insert Functions (3)
Click the formulas tab
Choose More FunctionsMore Functions
Choose one of the categories (e.g. statistical) and then choose the function or
click on the Insert Function fx button Insert Function dialog box appears
1
2
3
-
8/11/2019 Excel: How To
15/46
Insert Functions (4)
Click the Insert FunctionInsert Function ButtonButton on theformula bar
The Insert Function dialog box opens
In the Search for a function box, typea description of what you want to do.
Insert Functions (5)
Activate a cell and type =type =
Recent functionRecent function names displayedin the Name Box
Click the arrow to choose one
1
2
3
Text FormulasFunctionFunction ActionAction
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:LXSPPPRRRYYYYDDDGSIVVL = LandsatX = SensorS= SatellitePPP = WRS PathRRR = WRS RowYYYY = YearDDD = Julian Day of YearGSI = Ground Station IdentifierVV = Version
Sensor Examples:Sensor Examples:LM10170391976031AAA01 (MSS)LT40170361982320XXX08 (TM)LE70160392004262EDC02 (ETM+)
-
8/11/2019 Excel: How To
16/46
Basic Math Functions (1)FunctionFunction ActionAction
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)FunctionFunction ActionAction
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:ANDAND, FALSEFALSE, IFIF, NOTNOT, OROR&TRUETRUE
Examples: =IF(C5
-
8/11/2019 Excel: How To
17/46
If: Absolute Value Example The number to be evaluated is entered into cell A1
The formula is entered into cell B1
Logical FunctionsLogical Functions Comparison operators:Comparison operators:
OperatorOperator ExplanationExplanation
= Equal to
Not equal to
> Greater than
>= Greater than or equal to
< Less than
145",D17:D25)
Sums the cells in the D17:D25 range, where corresponding cellsin 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?
-
8/11/2019 Excel: How To
18/46
Logical Functions Note that text criteriatext criteria or any criteriaany criteria that includes
logical or mathematical symbols must be enclosed indouble quotation marks ("")
If the criteria is numeric, double quotation marks are notrequired
The concatenation operator (&) is used to join thesymbols (>) with cell references
Calculate the monthly payments required for a$900,000$900,000 loan amortized over 3030 years at aconstant interest of 5%5% per annum
Example: Financial Functions
SET UP THE PROBLEM Select the Financial Category
-
8/11/2019 Excel: How To
19/46
Select the PMT function
Choose the rate cellChoose the rate cellDivide by 12 to convert into monthly rateDivide by 12 to convert into monthly rate
Select the PMT function
NPER is the # of paymentsNPER is the # of payments Years *12Years *12
Select the PMT function
In PV (Present Value) Enter the loan amountIn PV (Present Value) Enter the loan amount
Select the PMT function
In PV (Present Value) Enter the loan amountIn PV (Present Value) Enter the loan amount
-
8/11/2019 Excel: How To
20/46
The monthly payment is now calculatedCheck the formula in the formula bar
Conclusion
No chance to buy a flat in Beirut except if I win thelottery soon
Other Important Functions
MatchMatch: 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, matchtypematchtype))
Specifying the matchtype is optional. Defaults to 1
Specifying -1: Finds the smallest value that is greater than orequal to value (the field has to be sorted in descending order)
Specifying 0: Finds the first value that is exactly equal to thevalue
Specifying 1: Finds the largest value that is less than or equalto value (the field has to be sorted in ascending order)
-
8/11/2019 Excel: How To
21/46
INDEX
Index: Returns a value within a table or range
If you give it an array:
Syntax: = INDEX(= INDEX(array,row_num,column_numarray,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
COUNTCOUNT: Counts the number of cells that containnumbers =COUNT(RANGE)
Arguments that are numbers, dates, or a textrepresentation of numbers
COUNTIFCOUNTIF: Counts the number of cells that fulfills oneor more criteria = COUNTIF(range, criteria)
COUNTACOUNTA: Counts the number of cells that are notempty in a specified range
It will count error values and empty text ("")
=COUNTA(RANGE)
Matrix Algebra in Excel Adding Two MatricesTo 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 ENTERkeys simultaneously
Pressing enter will get you an error message or the wrong answer!
Look at the formula: You should see bracesbraces surrounding the
array formula Matrix OperationMatrix Operation
-
8/11/2019 Excel: How To
22/46
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, ENTERto 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 errormessage
-
8/11/2019 Excel: How To
23/46
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 theformula area
Press CTRL, SHIFT, ENTER
If A is singular, then det(A) should be what?
Now you should be able tosolve systems of linear
equations in Excel
Formula Auditing Tools inExcel
To use theAuditing Tools in Excel click on the formula youwish to audit
Go to the Formulas tab in the Office RibbonOffice Ribbon
Trace PrecedentsTrace Precedents tool for a selected cell with a formula:ArrowsArrows will appear pointing to the cells included in formula
This helps you determine where the values that make upyour formula come from
Formula Auditing Tools inExcel
To use theAuditing Tools in Excel click on the formulayou wish to audit
Go to the Formulas tab in the Office RibbonOffice Ribbon
Trace DependentsTrace Dependents tool tells you which cells rely or aredependent on the selected cell
Great tool to use before you delete a cell!
-
8/11/2019 Excel: How To
24/46
Formula Auditing Tools inExcel
Show Formulas buttonShow Formulas button: Cells containing formulas willdisplay formulas
Error Checking buttonError Checking button: Make sure that the formulas youare using are all correct
Evaluate Formula toolEvaluate 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
MessageMessage ExplanationExplanation
#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 ErrorCircular Error Cell referring to itself
#NAME?#NAME? Undefined variable or function
#VALUE#VALUE Result of a mathematical operation on cells that contain both textand values
Excel issues an error message and suggests a correction if theformula expression is invalid
Integration in Excel
No built-in integration function in Excel
Will need to use numerical integration:
Rectangle Method
Trapezoid MethodTrapezoid Method
Simpsons Rule Method
Gauss Quadrature
Example: Trapezoidal rule in Excel
Suppose we have an object that is moving with avelocity that is described by this equation:
v = (v = (--0.011t0.011t33 -- 0.2t0.2t22 + 2.4t + 2)+ 2.4t + 2) m/sec
The object starts at --18 meters18 meters initially
Calculate the objects position after 10 seconds
Analytical solution is easy:
Position is the indefinite integral of the velocity
-
8/11/2019 Excel: How To
25/46
Trapezoidal Rule
//...///0.
Trapezoidal rule in Excel
1. First set up the problem
2. Calculate velocity over a range of t
3. Use the multiple segment trapezoidal rulemultiple 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 methodSimple difference method:
Forward (y1-y0)/h
Center (y1-y-1)/2h
Backward (y0-y-1)/h
Calculate the steps (x)
Get the slope (y2-y1)/(x)
Other methods (5-point stencil, differential quadrature)
VLOOKUP & HLOOKUP
VV= For Vertical/column lookup
HH = Horizontal/row lookup
Lookup functions are designed to
retrieve information from tabulardata based on certain specifications orconditionsconditions
-
8/11/2019 Excel: How To
26/46
HOW TO USE IT?
Think of the 3 Ws:Think of the 3 Ws:
WhatWhat is your lookup value?
WhereWhere to look up?
WhichWhich column holds your results?
VLOOKUP UsingVLOOKUPVLOOKUP is similar to looking up
a persons name in a telephone directory
to get his/her telephone number
VLOOKUPVLOOKUP looks at a value in one
column, and finds its corresponding
value on the same rowsame row in anotheranother
columncolumn
Similar to building a very simple query in
AccessAccess
VLOOKUP: Syntax=VLOOKUPVLOOKUP(lookup_value, table_array, col_index_number,
not_exact_match)
lookup_value: The value that the function will look for inthe left most columnleft most column
table_array: The table that the function will look through
col_index_number: The column number from which thefunction should return the value
not_exact_match: Can be either True or False
True = find the next largest value that is less than thelookup_value (default)
False = find exact match
VLOOKUP: Example
Question: find the pricefor item with ID #12
5050
5151
5353
5252
(12, 50:53 ,22, FALSEFALSE)
14.33
-
8/11/2019 Excel: How To
27/46
Common Mistakes withVlookup
You need to sort your result columnsort your result column in ascending order
when using Exact=FALSE
Excel does not interpolatedoes not interpolate valuesvalues
The # of the result column is from the beginning of thebeginning of the
rangerange and not from the beginning of the sheet
The lookup field has to be the leftmost fieldleftmost field
HLOOKUP: SIMILAR BUT FOR ROWS
=HLOOKUP (12, A1:E3, 2, False)=HLOOKUP (12, A1:E3, 2, False) Look in 2nd row for thevalue corresponding to 12 in top row, and look for exact match 114.334.33
=HLOOKUP (10, A1:E3, 2, False)=HLOOKUP (10, A1:E3, 2, False) Look in the 2nd row for thevalue corresponding to 10 in top row, and look for exact matchto 10 #N/A#N/A
=HLOOKUP (50, A1:E3, 3, True)=HLOOKUP (50, A1:E3, 3, True) Look in the 3rd row for thevalue corresponding to 50 in top row. No 50 but not exactMatch 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:
TRUETRUE option is selected (default) an approximate match
The value searched for is rounded downrounded 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 numericfields in your table
3. Generate charts from your pivot tables
Similar to Crosstab in AccessSimilar to Crosstab in Access
-
8/11/2019 Excel: How To
28/46
Before You Begin: A Note About Pivot Tables
Data should be arranged in a list:
ColumnsColumns represent fields
RowsRows represent a record of related data
First rowFirst row == Column labelColumn 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 databecomes 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 RibbonInsert Ribbon, go to Tables groupTables group, click PivotTablePivotTable
3. The Create PivotTableCreate 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 isnew sheet)
Pivot Table (II)After you close the Create PivotTableCreate PivotTable dialog box you
should see:1. On one side the Layout AreaLayout Area ready for the PivotTable report
2. On the other side the PivotTable Field ListPivotTable 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 FilterReport Filter
2.2. Column LabelsColumn Labels
3.3. Row LabelsRow Labels
4.4. ValuesValues
No need to useALLALL youryour fields!
No need to fillALLALL 4 areas! 11 22
33 44
-
8/11/2019 Excel: How To
29/46
Pivot Table (IV)
If you click outside the layout area of a PivotTable report the PivotTable Field ListPivotTable Field List goes away
To get the field list back, click inside the PivotTable layoutarea or report
You can SORTSORT the data only by the fields in the RowRowLabelsLabels
Unlike Access you can have multiple column labelsmultiple column labels
Note that you may create a PivotTable based on anexternal data source
Pivot Table (V)
A PivotTable report with more than one row field has:
One Inner RowInner Row field (closest to the data area)
and other Outer RowOuter Row fields
Items in the outermostoutermost 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 totalA column total
A row totalA row total (if you have multiple columns)
Cell Referencing to a PivotTable GETPIVOTDATAGETPIVOTDATA 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!
-
8/11/2019 Excel: How To
30/46
Cell Referencing to a PivotTable
GOAL SEEK
Goal SeekGoal Seek allows us to conduct whatwhat--if analysisif analysis
Use Goal SeekGoal Seek when you know the desired resultdesired result ofa single formula but not the input value needed to getthe result
The command uses iterationsiterations to obtain the desiredresults
Goal SeekGoal Seek uses a process of changing the values incells to see how those changes affect the outcome offormulas on the worksheet
Goal Seek: How To? Go to the Data RibbonData Ribbon
Go to the Data ToolsData Tools group
ClickWhatWhat--If AnalysisIf Analysis
ClickGoal SeekGoal 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
-
8/11/2019 Excel: How To
31/46
Goal Seek: Troubleshooting Make sure the Set cell referenceSet cell reference is to a cell that
contains a formula, function, or cell referenceformula, function, or cell reference
Make sure the To value cellTo value cell value is a reasonablevalue
Make sure the By changing cell referenceBy changing cell reference is not aformula, function, or a cell reference
Make sure there is a link by formulas between thetwo cells you entered in the Goal SeekGoal Seek
However complicated the link might be, they MUSTMUST
BEBE related
Root-Finding with Excel
Can we use Goal Seek to find the root of anequation?
Yes!Yes!
Identify one cell to hold the value of the independentvariable (let us call it x)
In another cell put the formula for f(x)
Guess a plausible estimate of a root and input it inthe first cell
Select the Goal SeekGoal Seekfunction
Set the target value to 00
Example
What are the roots of:
Excel Shortcomings
Excel will find one of the rootsone 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 yourinitial guess
-
8/11/2019 Excel: How To
32/46
Optimizing in Excel: Solver
First need to add Solver to Excel:
Check to see if you have it under the Data RibbonData Ribbon
If not then:
Go to the Microsoft ButtonMicrosoft Button
Click on Excel OptionsExcel Options
Go to theAddAdd--Ins TabIns Tab
In the ManageManage box, select Excel AddExcel Add--insins
In theAddAdd--InsIns available box, select the Solver AddSolver Add--inincheck box, and then click OKOK
Adding Solver
Solver in Excel
You should see the SolverSolver under the DataDataRibbonRibbon,Analysis GroupAnalysis Group
Optimizing in Excel: Solver
An optimization model in Excel has 3 parts:
The target cellThe target cell
The changing cellsThe changing cells
The constraintsThe constraints
Solver helps find optimal values in one or more
cells, called the target cell(s)target cell(s), by changing achanging agroup of cellsgroup of cells to find an optimal value subject tothe constraintsconstraints that you set
-
8/11/2019 Excel: How To
33/46
Target Cells
The target cell represents the objectiveobjective or goalgoal
Usually we want to either minimizeminimize or maximizemaximize thetarget cell
Maximize orMaximize or minimizeminimize Target cellTarget cell
MaximizeMaximize Monthly profitMonthly profit
Minimize Distribution costs
Maximize Net present value contributed by selected projects
MinimizeDifference between scores predicted by ratings andactual scores
Minimize Riskiness of portfolio
Changing Cells
Changing cells are the spreadsheet cells that we wantto changechange or adjustadjust to optimize the solution in thetarget cell
Changing cellsChanging cells
Amount of each product produced during the monthAmount of each product produced during the month
Amount produced at each plant each month that is shippedto each customer
Team ratings
Fraction of money invested in each asset class
Constraints Constraints are restrictionsrestrictions we place on the changing
cells to constrain our solution
They need to be acheived
ConstraintsConstraintsProduct mix uses no more resources than are availableDo not produce more of a product than can be soldDo 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 pricesProjects selected can't use more money or skilled programmers thanare available
NoneNone
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 ProfitGoal: Maximize Profit
-
8/11/2019 Excel: How To
34/46
Constraints Constraints on Building
1. Can not exceed inventory of products
2. Need to build at least 5 unitsat least 5 units of each type
3. Can not build more than 500 units of any type500 units of any type
4. The number of units in each category has to be
an integer and positiveinteger and positive
Example 2: ChemicalProcurement
A company manufactures 3 types of chemicals3 types of chemicals
It has a contract to supply its customers with thefollowing amounts of the three chemicals:
Chemical 1 Chemical 2 Chemical 3Contracted Sales (lbs) 2000 3500 1800
Chemical Procurement Production is limited by the availability of processing
time in the two chemical ovenstwo chemical ovens
Each chemical must be processed first in Oven 1and then in Oven 2
Hours of processing timeprocessing time available for each ovenand the processing time required in each oven foreach chemical is:
Reactor Processing TimesReactor Processing Times(hrs per lb)(hrs per lb)
Chemical 1 Chemical 2 Chemical 3ReactorReactor
AvailabilitiesAvailabilities
(hrs)(hrs)Oven 1 0.05 0.04 0.01 200200Oven 2 0.02 0.06 0.03 150150
-
8/11/2019 Excel: How To
35/46
Chemical Procurement
Because of the limited availability of Ovenprocessing time, there is insufficient capacityinsufficient capacityto meet the demand with in-house production
Must purchase some chemicals from vendors
The following table provides each chemicals inin--househouse production cost and outsideoutside purchasecost:
Chemical 1Chemical 1 Chemical 2Chemical 2 Chemical 3Chemical 3
InIn--house Productionhouse Production Cost ($/lb)Cost ($/lb) $2.50 $1.75 $2.90Outside PurchaseOutside Purchase Cost ($/lb)Cost ($/lb) $2.80 $2.50 $3.25
QUESTION
Which chemicals should we buy from theoutside suppliers?
How much of each chemical should we producein-house?
Goal: Minimize CostGoal: Minimize Cost
Constraints Constraints Need to fullfill the customers orders
Need the cheapest combination of in-houseproduction and outside purchases
Can not exceed the amount of operational time in the2 ovens
Amounts produced and bought need to be > 0
Must decide how muchhow much of each chemical toproduce inproduce in--househouse (i.e., make) and how much
of each chemical to purchase outsidepurchase outside (i.e.,buy)
-
8/11/2019 Excel: How To
36/46
Solver Options: Accuracy Max time:Max time: Limits the time taken by
the solution process
Iterations:Iterations: Limits the number ofinterim calculations
Precision:Precision: Controls the precision ofsolutions
Tolerance:Tolerance: The % by which thetarget cell can differ from the trueoptimal value
Convergence:Convergence: When the relativechange in the target cell value is lessthan the selected number for thelast 5 iterations Solver stops
Must be indicated by a fractional
between 0 and 1
Solver Options: Assumptions
Radio buttonsRadio buttons tochoose from dependingon your problem
E.g Choose linear modelif all relationships in themodel are linear andyou want to solve alinear optimizationproblem
Solver Options: Estimates
Specifies the approachthat is used to obtaininitial estimates of thebasic variables
Choose quadratic whenthe problem is non-linear
Solver Options: Derivatives
Specifies the
differencing that is used
to estimate derivatives
Forward
Central
-
8/11/2019 Excel: How To
37/46
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 aA Picture is Worth aThousand WordsThousand Words
First quoted in 1911
Excel Chart Types There are 1111 major chart types in Microsoft Excel
Each has its own set of chart subtypessubtypes
-
8/11/2019 Excel: How To
38/46
Creating a Basic Graph inExcel
4 clicks4 clicks between you and a graph:
1. Use the mouse to select the dataselect the data
To select noncontiguous data in a spreadsheet, hold down
CtrlCtrl button while dragging mouse to select cells
2. Go to the Insert RibbonInsert Ribbon
3. Go to the Charts GroupCharts Group
4. Click on the chart typechart 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; butbut
Big difference in the way each of these chart types plotsdata along thexx--axis:axis:
Scatter chart displays numerical values along thehorizontal and the vertical axis
A scatter chart will not display categories on horizontal axis
Line chart distributes category or time interval data
evenlyevenly along a horizontal axis (even if numeric)
Know exactly what you want!
3 D Plots
Surface charts generate three dimensional surfacethree dimensional surface
Colors and patterns in a Surface chart indicate areasthat contain the same range of valuesrange of values
Need to organize the data in your worksheet:
-
8/11/2019 Excel: How To
39/46
Excel: Surface Chart Types
4 Major types4 Major types
Creating a Surface Chart
1. Select the data you want to display in aSurface 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 youwant to use
5. Click Next
Surface Plots Editing a Chart in Excel When a chart is created and/or selected, the ChartChart
ToolsTools appear in the Excel Ribbon
Design TabDesign Tab
Layout TabLayout Tab
Format TabFormat Tab
-
8/11/2019 Excel: How To
40/46
Chart Tools Within the Design tabDesign tab you can control the chart type, data, layout,styles, and location
Within the Layout tabLayout tab you can control current selection, insertingpictures, shapes and text boxes, labels, axes, background, and analysis
Within the Format tabFormat 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 tabDesign tab
Click on Change Chart TypeChange Chart Type
Select a new graph from the Chart TypeChart Type dialog box thatappears
ClickOKOK
Adding Chart Elements
There are 15 chart elements15 chart elements that can be added to a chart inExcel
Adding a Chart TitleAdding a Chart Title
Adding AxesAdding Axes
Adding a LegendAdding a Legend
Adding Data LabelsAdding Data Labels
Adding a Data TableAdding a Data Table
Adding GridlinesAdding Gridlines
Adding Chart Elements
There are 15 chart elements15 chart elements that can be added to a chart
Excel has predefined chart layouts located in the DesignDesigntabtab that include many of these elements already added
-
8/11/2019 Excel: How To
41/46
Adding Chart Elements
There are 15 chart elements15 chart elements that can be added to a chart
Excel has predefined chart layouts located in the DesignDesigntabtab that include many of these elements already added
You can manuallymanually add individual chart elements to your graphby using the options located in the Layout tabLayout tab
Click on the Layout tabLayout tab and locate the appropriate LabelLabelgroup:group: Click on down arrow on Chart Title buttonChart Title button (select a title layout)
Click on down arrow for theAxis Titles buttonAxis Titles button (add title to chart axis)
Click on down arrow for the Legend buttonLegend button (add legend)
Click on down arrow for the Data Labels buttonData Labels button (add values to graph)
Click on down arrow for the Data Table buttonData Table button (add data as table) Check the different options +Check the different options +MoreOptionsMoreOptions
Formatting Axes Select your charts X or Y axis
Click on the Layout tabLayout tab
Click the Format SelectionFormat Selectionbutton under Current Selectiongroup
Under Axis Options you can makemany changes:
Min-Max
Log scale
Tick marks
Change color of axis line
You can also access it from theAxes GroupAxes Group under LayoutLayout
Axis: Primary and Secondary
-
8/11/2019 Excel: How To
42/46
Adding a Second AxisYou can plot one or more data series on a secondary axissecondary axis
Good when you have 2 series that have a wide range orare 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 secondaryaxis
Go to the FormatFormat menu
Click the Selected Data SeriesSelected Data Series icon under the CurrentCurrentSelection groupSelection group
Under theAxisAxis tab, click Secondary AxisSecondary Axis
Adding a Second Axis
One Chart 2 Chart Types
You can plot one or more data series in the same chartbut with different chart types
How to do it?
Click the data series that you want to change its type
Go to the DesignDesign menu
Click the Change Chart TypeChange Chart Type icon under the TypeType groupgroup
Select the new type
Press OKOK
Note that the 2 types have to be compatiblecompatible
One Chart 2 Chart Types
-
8/11/2019 Excel: How To
43/46
Adding a Trend Line andRegression Equation
You can add a trendline to any data series (given a chart type)
Trendlines are regression modelsregression models that Excel adds to yourgraph
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 LinesLinearLinear trendlinestrendlines (best-fit straight line)
LogarithmicLogarithmic trendlinestrendlines (best-fit curved line whenthe rate of change in the data increases or decreases quicklyand then levels out)
PolynomialPolynomial trendlinestrendlines (best curved line, nth degree)
PowerPower trendlinestrendlines (curved line when increase is at aspecific rate)
ExponentialExponential trendlinestrendlines (values rise or fall atconstantly increasing rates)
Moving averageMoving average trendlinestrendlines
TypeType EquationEquation
Linear
Logarithmic (semi)
Polynomial
Power
Exponential
Moving average
Trend Lines Add a Trendline and ItsEquation
Click anywhere in the chart
Select the series
Right click and selectAdd trendline
Choose the appropriateappropriate trendlinetrendline
Select any appropriate options:
Forecast Hindcast
Intercept
Choose to display RR22 and the equation of the line
-
8/11/2019 Excel: How To
44/46
Reminder: What is R2 ? It is the Coefficient of determinationCoefficient of determination
Between 0 and 10 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 barchart, the trendline is calculated based on theassumption that the x values are 1, 2, 3, 4, 5, 6, etc
This assumption is made even if the x-values arenumeric or text!
To base a trendline on numeric x values, you should use anxyxy (scatter) chart(scatter) chart
If you add a moving averagemoving average to an xy (scatter) chart:
Moving average is based on the order of the x valuesplotted in the chart
To get the result that you want, you have to make suremake surethatthat the x values are ordered as you want before you addthe 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 thespreadsheet to be printed
Click Print TitlesPrint Titles to access advanced Page Setup setting:
Rows and columns repeat on multiple pages
-
8/11/2019 Excel: How To
45/46
Printing in Excel (2)You can insert a Break:
Select a cell below where you want the break to appear
Select the BreaksBreaks command
Select Insert Break
To print a graph by itself:
Select the graph
Click Ctrl+P to open the Printdialog 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 characterseparates each field of text (ASCII)
Comma separated files ..csvcsv files
You can also change the separator character used
For text files other than .csv you will get the Text ImportText ImportWizardWizard
You can import or export up to 1,048,576 rows and 16,384columns
.dbf (dBase III and IV) can be opened in Excel, but youcannot save an Excel file to dBase format
Exporting from ExcelYou 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:
..csvcsv
.txt.txt
Note that formatting, graphics, and other objects will be
lost when saving data in a .txt or .csv fileYou 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
-
8/11/2019 Excel: How To
46/46
Protect SheetProtect Cells and Sheets
a.HomeFormatProtect Sheet
b.Review Tab Changes Protect
Sheet
Questions?Questions?