ExcelNotes

advertisement
ITOM 2308
Lecture Notes
for
Excel
1
Formulas
Printing the formulas in an Excel Worksheet
Show Formulas
Individual column widths can be adjusted to show the complete formula…
O the "Print" screen, use:
Page Setup
Sheet
Gridlines
 Row and Column Headings
to print the row and column headings as well as the
gridlines.
2
About cell and range references
A reference identifies a cell or a range of cells
on a worksheet and tells Microsoft Excel
where to look for the values or data you want
to use in a formula. With references, you can
use data contained in different parts of a
worksheet in one formula or use the value
from one cell in several formulas. You can
also refer to cells on other sheets in the same
workbook, and to other workbooks.
References to cells in other workbooks are called
To refer to
Use
The cell in column A and row 10
A10
The range of cells in column A and rows 10 through 20
A10:A20
The range of cells in row 15 and columns B through E
B15:E15
The range of cells in columns A through E and rows 10 through 20
A10:E20
links.
Absolute cell references
In a formula, the exact address of a cell, regardless of the position of the cell that contains the formula. An absolute cell
reference takes the form $A$1.
The A1 reference style:
By default, Excel uses the A1 reference style, which refers to
columns with letters (A through IV, for a total of 256
columns) and refers to rows with numbers (1 through
65536). These letters and numbers are called row and
column headings. To refer to a cell, enter the column letter
followed by the row number. For example, B2 refers to the
cell at the intersection of column B and row 2.
Reference (Description)
Changes to
$A$1 (absolute column and absolute row)
$A$1
A$1 (relative column and absolute row)
C$1
$A1 (absolute column and relative row)
$A3
A1 (relative column and relative row)
C3
The difference between absolute, relative and mixed cell references
Relative references
A relative cell reference in a formula, such as A1, is based on the
relative position of the cell that contains the formula and the cell the reference refers to.
If the position of the cell that contains the formula changes, the reference is also
changed. If you copy or fill the formula across rows or down columns, the reference
automatically adjusts. By default, new formulas use relative references. For example, if
you copy or fill a relative reference in cell B2 to cell B3, it automatically adjusts from =A1
to =A2.
Absolute references
An absolute cell reference in a formula, such as $A$1, always refer to a cell in a specific location. If the position of
the cell that contains the formula changes, the absolute reference remains the same. If you copy or fill the formula
across rows or down columns, the absolute reference does not adjust. By default, new formulas use relative
references, and you may need to switch them to absolute references. For example, if you copy or fill an absolute
reference in cell B2 to cell B3, it stays the same in both cells =$A$1.
Mixed references
A mixed reference has either an absolute column and relative row, or absolute row and
relative column. An absolute column reference takes the form $A1, $B1, and so on. An absolute row reference
takes the form A$1, B$1, and so on. If the position of the cell that contains the formula changes, the relative
reference is changed, and the absolute reference does not change. If you copy or fill the formula across rows or
down columns, the relative reference automatically adjusts, and the absolute reference does not adjust. For
example, if you copy or fill a mixed reference from cell A2 to B3, it adjusts from =A$1 to =B$1.
3
Using the FREQUENCY function in Excel
Calculates how often values occur within a range of values, and then returns a vertical array of numbers. For
example, use FREQUENCY to count the number of test scores that fall within ranges of scores. Because
FREQUENCY returns an array, it must be entered as an array formula.
=FREQUENCY(DataRange,IntervalRange)
DataRange is an array of or reference to a set of values for which you want to count frequencies. In the example
below, DataRange the cell-range F2:F11. (The column heading is not included in this range.) If any values in the
DataRange contain no values, FREQUENCY returns a zero.
IntervalRange is the interval range; that is, an array of or reference to intervals into which you want to group the
values in DataRange. In the example below, the IntervalRange is B15:B18. The number of elements in the
returned array is one more than the number of elements in interval range. The extra element in the returned array
returns the count of any values above the highest interval. For example, when counting three ranges of values
(intervals) that are entered into three cells, be sure to enter FREQUENCY into four cells for the results. The extra
cell returns the number of values in the data range that are greater than the last interval value.
Remarks:
FREQUENCY is entered as an array formula after you select a range of adjacent cells into which you want the
returned distribution to appear. In the example below, notice that the range selected is C15:C19.
Example:
This is the worksheet named
FREQUENCY.xls.
Procedure:
1. The formula in the example must be
entered as an array formula. Type in
the values of the upper limits of the
desired intervals for the Balance Due
in the range B15:B19 as seen in the example above. In this case, we are assuming we want the
frequency of the balances due as shown, above, in the C15:C19 range.
2. Next, select the area where you want the frequencies to appear. In this example, it is the cell range
C15:C19.
3. Now, type in the frequency expression as: =FREQUENCY(F2:F11,B15:B18)
and then press CTRL+SHIFT+ENTER. (This means while holding down CTRL and SHIFT
simultaneously, strike the ENTER key.)
4
The SUMPRODUCT Function
Multiplies corresponding components in the given arrays, and returns the sum of those products.
Syntax: SUMPRODUCT(array1,array2,array3, ...)
Array1, array2, array3, ... are 2 to 30 arrays whose components you want to multiply and then add.
 The array arguments must have the same dimensions. If they do not, SUMPRODUCT returns the
#VALUE! error value.
 SUMPRODUCT treats array entries that are not numeric as if they were zeros.
Example 1:
A
B
1
3
2
3
C
D
E
4
2
7
8
6
6
7
1
9
5
3
4
156
The following formula in Cell C4 multiplies all the components of the two arrays on the
worksheet and then adds the products:
=SUMPRODUCT(A1:B3,D1:E3)
Numerically this is: 3*2 + 4*7 + 8*6 + 6*7 + 1*5 + 9*3 = 156.
Example 2:
1
2
3
A
3
8
1
B
4
6
9
4
10
20
The formula set up in Cell D1 is:
C
D
110
E
=SUMPRODUCT(A1:B1,$A$4:$B$4)
Numerically this is: 3*10 + 4*20 = 30 + 80 = 110.
If the contents of Cell D1 are copied to Cells D2 and D3, what numbers will be displayed in
those cells?
5
The MIN Function:
=MIN(number1,number2,...)
where number1, number2, ... are 1 to 255 numbers for which you want to find the minimum value.
Remarks
 Arguments can either be numbers or names, arrays, or references that contain numbers.
 Logical values and text representations of numbers that you type directly into the list of arguments are
counted.
 If an argument is an array or reference, only numbers in that array or reference are used. Empty cells,
logical values, or text in the array or reference are ignored.
 If the arguments contain no numbers, MIN returns 0.
 Arguments that are error values or text that cannot be translated into numbers cause errors.
 If you want to include logical values and text representations of numbers in a reference as part of the
calculation, use the MINA function.
Example:
The expression in Cell B8 is: =MIN(B2:B6)
=MIN(B2:B6,0) would return the smallest number from zero or above.
The MAX Function:
=MAX(number1,number2,...)
where number1, number2, ... are 1 to 255 numbers for which you want to find the maximum value.
It is identical to the MIN function, except it returns the maximum value of an array of numbers.
6
The IF Function
Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE. Use the IF function to
conduct conditional tests on values and formulas.
=IF(logical test, value if "true", value if "false")
Logical test is any value or expression that can be
evaluated to TRUE or FALSE. For example, A10=100
is a logical expression; if the value in cell A10 is
equal to 100, the expression evaluates to TRUE.
Otherwise, the expression evaluates to FALSE. This
argument can use any comparison calculation
operator.
Value if "true" is the value that is returned if
logical test is TRUE. For example, if the following
IF function appears in a cell and the value if "true"
value is the text string "Within budget" and the
logical test argument evaluates to TRUE, then the
IF function displays the text "Within budget". On the
other hand, if logical test is FALSE, then "Over
Budget" will appear in the cell with the IF function.
=IF(B3<D3,"Within Budget", "Over Budget")
For example: =IF(B4>=100, A2*A1, 0)
Comparison operator
Meaning (Example)
= (equal sign)
Equal to (A1=B1)
> (greater than sign)
Greater than (A1>B1)
< (less than sign)
Less than (A1<B1)
>= (greater than or equal to sign)
Greater than or equal to (A1>=B1)
<= (less than or equal to sign)
Less than or equal to (A1<=B1)
<> (not equal to sign)
Not equal to (A1<>B1)
If the logical test is TRUE and value if true is blank, this argument returns 0 (zero). Value if true can be another formula.
Value if "false" is the value that is returned if logical test is FALSE. For example, if this argument is the text string "Over
Budget" and the logical test argument evaluates to FALSE, then the IF function displays the text "Over Budget". If logical
test is FALSE and value if false is omitted, (that is, after value if true, there is no comma), then the logical value FALSE is
returned. If logical test is FALSE and value if false is blank (that is, after value if true, there is a comma followed by the
closing parenthesis), then the value 0 (zero) is returned. Value if false can be another formula.
Microsoft Excel provides additional functions that can be used to analyze your data based on a condition. For example, to count
the number of occurrences of a string of text or a number within a range of cells, use the COUNTIF worksheet function. To
calculate a sum based on a string of text or a number within a range, use the SUMIF worksheet function.
Example 1: The example may be easier to understand if you copy it to a blank worksheet.
Example 2:
7
Example 3: In this example, the weekly wage for an employee is calculated as the Pay Rate times the number of hours worked
(Hours). However, if the employee records a number of hours greater than forty, then the hours over forty worked by the
employee must be paid at the rate of 1.5 times the Pay Rate. In the spreadsheet below the IF function used in Cell G4 is
depicted.
8
VLOOKUP
The use of the vertical look up function is to search for a value in the leftmost column of a table, and then return a value in the
same row from a column you specify in the table. The figure to the right is the look up table I use in
my Excel grade sheets. This table is used to determine your letter grades based on your course
average. For example, if your course average is 92.3, then the look up table, when appropriately
referenced, will return the grade of A-.
The first column in the look up table is made of the values that determine which row in the table is
referenced when compared to an external value. The row that is picked is the one in which the
external value is equal to or greater than, yet not equal to the value below it. (The values in the first
column must be in numerical order.) In the example above, 92.3 is greater than 90.0, yet less than
94.0, so the 90.0 row is chosen.
The form of the function is:
VLOOKUP(lookup value, lookup table range, column number, range-lookup)
Here’s an example of the use of the VLOOKUP function. In this worksheet, the carrying cost of an
item depends on its annual usage. This is reflected in the values in the look up table as depicted in
cells B13:C17. If the annual usage is from zero to less than 500 units/year, then the annual carrying
cost is 30% of the item’s value. If the annual usage is from 500 to less than 1000 units/year, then
this carrying cost is 25%: etc.
Notes:
 If range-lookup is either TRUE or is omitted, the values in the first column of lookup table range
must be placed in ascending sort order; otherwise, VLOOKUP might not return the correct value.
 If range-lookup is specified as FALSE, the values in the first column of do not need to be sorted.
 If the range-lookup argument is specified as FALSE, VLOOKUP will find only an exact match. If there
are two or more values in the first column of lookup table range that match the lookup value, the first
value found is used. If an exact match is not found, the error value #N/A is returned.
9
Create a PivotTable Report in Excel – An Example
Suppose you want to create the PivotTable report from the following data. In this case, you want to display the sum of the
Balance Due by the State cross-referenced by the Therapist Number.
This is what the resulting Pivot Table should look like:
1. Select the area in the spreadsheet that contains the data. Include column headings in this area.
2. On the Insert tab, click on the PivotTable button.
10
3. The next step is to specify the range to use (if
selected the range in Step 1, above, it will show up
in the "Table/Range" box as depicted below.) Next
choose where you want the pivot table to be placed
in the workbook. Usually, it is best to place it in a
new worksheet.
4. After clicking on the "OK" button above, check the boxes under "Choose fields to add to report:". You can drag the field
names from the original data area to create column headings on the pivot table. In this case, we wanted the Therapist Number
to be in the rows of the pivot table, the State to be in the columns, while the data to be summed is the Balance Due. After this
is done, the pivot table appears as shown below.
11
Special Note: Use the Options… button if you want to change what will show in the empty cells of the pivot table. The default
is a blank cell.
When you click on "Options", the screen below appears. Merely type in the value (text or a number) for the cells in the pivot
table which are empty. In this example. I typed in the word "None" as shown below.
The pivot table may be formatted to be appearing more organized.
When you are satisfied with the layout, close the "PivotTable Field List"
window.
Close this window
when the Pivot table
is completed.
12
Create a One Variable Data Table – An Example
In order to analyze data with regards to changes in some independent variable in a worksheet, a Data Table is useful to
examine "what if" scenarios.
Suppose we develop a spreadsheet that depicts several inventoried items that have a common annual carrying cost of 15% of
the items value. Given the annual usage (U), the cost to place an order (Co), and the cost of the item (C), we can easily
determine the most economic order quantity (EOQ) for each item in the product group. From this, the total annual inventory
cost is calculated in column H.
As an inventory analyst, I might be curious as to how the EOQ in Cell F4 and the total annual cost in Cell H4 would change for
changes in the annual carrying cost percentage for Part A. Currently, it is set at 15%, but I would like to see the resulting EOQs
and annual costs for varying values of the annual carrying cost percentage, say, for Part A. This is a good scenario for setting up
a data table in the worksheet.
1. Set up
the
data table in the worksheet by placing cell references to the values resulting from the changes in the independent variable (the
15% annual carrying cost percentage) in the first row of the table.
2. Next, type in the all the desired constant values for the independent variable in the first column of the table area.
The upper-left
corner of the data
table is the Cell E13
and it is left blank.
The expression in
Cell G13 is: =H4
The expression in
Cell F13 is: =F4
13
3. First, highlight the data table area on the worksheet as illustrated below.
First, select the entire
data table.
4. In Excel 2007, go to the Data tab, click on the What-If Analysis option, and then click the Data Table… option as
illustrated below.
5. For the Table screen, select the Column input cell as Cell C11, the cell in which the constant value for the annual
inventory carrying cost percentage resides. (The values in the first column of the data table will be fed into Cell C11, one at a
time.)
Cell C11 contains the
original Percentage.
6. Finally, click the OK button.
This is the resulting Data Table:
14
Create a Two Variable Data Table – An Example
Using the same spreadsheet developed the several inventoried items, suppose we want to examine the effect of changing order
costs (Co), in combination with variable annual carrying costs on the economic order quantity (EOQ). We want to examine what
the results of varying two independent variables will be on the one dependent variable, EOQ.
In this case, I want to see what different combinations of the annual carrying cost percentage and the order cost ($20 for Part
A, below) will influence the EOQ in Cell F4.
1. In this data table, the incremental values representing first variable (the 15% annual carrying cost percentage) are typed in
the first column of the table (10%, 12%, 14%, etc.). Next, the incremental values for the second variable, the annual order cost
for Part A, are typed as in subsequent columns of the data table in the first row of the table ($15, $20, $25, and $30). Finally,
in the upper-right corner of the table, type in the expression =F4. The idea is to compute the EOQ for part A (Cell F4) for every
combination of the Order Cost (Co) and the annual carrying cost (I) given in the data table.
This is Cell F4.
The expression in
Cell B13 is: =F4
15
2. Now, first, highlight the data table area on the
worksheet, and then select the commands Data and
then Table from the excel menu.
3. For the Table screen, select the Row input cell as Cell C$, the cell in which the constant value for the order cost for Part A
resides. (The values in the first row of the data table will be fed into Cell C4, one at a time.)
4. Next, specify Column input cell as Cell C11, the cell in which the constant value for the annual inventory carrying cost
percentage resides. (The values in the first column of the data table will be fed into Cell C11, one at a time.) Finally, click the
OK button. The resulting Data Table is depicted below.
16
Exponential Smoothing - Using Excel's Solver to Determine an Optimal Smoothing
Constant
17
Excel Functions used to determine a Linear Trend Line or a Regression Line
Using this example, the following functions were used to determine the Regression Line values:
The slope of the regression line in Cell G3:
=SLOPE(C3:C12,B3:B12)
Where, in general
=SLOPE(y-values,x-values)
The Y-Intercept of the regression
line in Cell G4:
=INTERCEPT(C3:C12,B3:B12)
The Coefficient of Correllation for
the regression line in Cell G5:
=CORREL(C3:C12,B3:B12)
The Coefficient of Determination is
the Coefficient of Correllation squared, so the expression in Cell G6 is:
=G5^2
The regression line values are determined by the following expression in Cell D3:
=$G$4+$G$3*B3
(This expression was copied
down from cell D3 through cell
D12.)
18
Using Excel to Generate Random Outcomes from a Probability Distribution
Normal Distribution:
Suppose a process is random, but
follows a normal distribution with a
mean of 50 and a standard deviation
of 8.
The RAND() function generates a
random number between 0 and 1.
Suppose in this illustration,
RAND() = 0.2284.
=8
.2704
.2284
50
X = 44.08
VARIBLE BEING
SIMULATED
The simulated variable is calculated
as follows:
a) Look up the normal table area of 0.5000 – 0.2284 = .2716 and determine the z-value for the area of
0.2716, and
b) The closest area is .2704, so use the z-value of -0.74 to determine the randomly generated variable.
The value of the variable is computed as:
X =  + z = 50 + (-0.74)(8) = 44.08
Uniform Distribution:
A uniform distribution means all values
have an equal probability of occurring. In
case, the random variable can vary
uniformly from 20 to 80.
this
.7730
To generate a random value from a uniform
distribution, again use RAND() to produce
an
66.38
20
80
area from the uniform distribution to
determine a value for the variable in
question.
The simulated variable is calculated by using the randomly generated value as the left portion of the
distribution's area.
For example, suppose RAND() = .7730
Then the variable will be:
X = 20 + .7730(80 – 20)
X = 20 + 46.38
X = 66.38
Excel Functions used in Simulation
RAND( )
RAND Returns an evenly distributed random number greater than or equal to 0 and less than 1. A new random
number is returned every time the worksheet is calculated.
Remarks

To generate a random real number between a and b, use:
RAND()*(b-a)+a
19

If you want to use RAND to generate a random number but don't want the numbers to change every time
the cell is calculated, you can enter =RAND() in the formula bar, and then press F9 to change the formula
to a random number.
Examples
To generate a random number greater than or equal to 0 but less than 100:
RAND()*100
Excel Functions used to Generate Random Numbers
RANDBETWEEN
Returns a random number between the numbers you specify. A new random number is returned every time the
worksheet is calculated.
If this function is not available, run the Setup program to install the Analysis ToolPak. After you install the Analysis
ToolPak, you must enable it by using the Add-Ins command on the Tools menu.
RANDBETWEEN(bottom,top)
Bottom is the smallest integer RANDBETWEEN will return.
Top is the largest integer RANDBETWEEN will return.
Note: To return an evenly distributed random number greater than or equal to 0 and less than 1 every time the
worksheet is calculated, use the RAND worksheet function. To return a random number between numbers you
specify every time the worksheet is calculated, use the RANDBETWEEN worksheet function.
ROUND
Rounds a number to a specified number of digits.
ROUND(Number, NumOfDigits)
Number is the number you want to round. (It can be a cell reference.)
NumOfDigits specifies the number of digits to which you want to round number .
Remarks:
 If NumOfDigits is greater than 0 (zero), then number is rounded to the specified number of decimal
places.
 If NumOfDigits is 0, then number is rounded to the nearest integer.
 If NumOfDigits is less than 0, then number is rounded to the left of the decimal point.
NORMINV
Generates an "X" value for a specified probability of the normal cumulative distribution for a specified mean and
standard deviation.
NORMINV(probability, mean, standard-dev)
Probability is a probability corresponding to the normal distribution.
Mean is the arithmetic mean of the distribution.
Standard_dev is the standard deviation of the distribution
Example using the NORMINV function:
In Cell B7:
=RAND()
In Cell C7:
=NORMINV(B7,$B$3,$B$4)
20
Download