Professional Documents
Culture Documents
S1 - 2021 BFF5255 Lecture Week 01 - Excel Techniques 1
S1 - 2021 BFF5255 Lecture Week 01 - Excel Techniques 1
In Excel, the function procedure performs a task and then returns control to
the calling code; When it returns control, it also returns a value to the calling
code
A function procedure can take arguments, such as a constants, variables, or
expressions, which are passed to it by the calling code.
For example: PV(rate, nper, pmt, fv, type)
rate, nper, pmt, fv and type are the function’s ‘parameters’ or ‘arguments’
The function (i.e., in this example, PV()) receives the ‘passed’ values and then
perform the task
Excel functions – Function procedures
Financial functions
Date functions
Statistical functions
Conditional functions
Regression functions
Logical functions
Matrices and Array functions
Other functions
Financial functions – PV function
Example
FV(10%, 3, 0, -1000) = $1000*1.13 = $1,331
FV(10%, 3, -100) = $100*1.12 + $100*1.1 + 100 = $331
FV(10%, 3, -100, 0, 1) = $100*1.13 + $100*1.12 + 100*1.1 =
$364.10
Financial functions – PMT function
Example
PMT(10%, 3, -248.69) = $100
PMT(10%, 3, -273.55, 0, 1) = $100
Exercise 1
Financial functions – NPV function
Exercise 4
Date-related functions
The EDATE(start_date, months) and EOMONTH(start_date, months)
functions can be useful in some financial applications. The
EDATE(start_date, months) function returns the same day of the month
after a specified number of months. The EOMONTH(start_date, months)
function returns the last day of any given month.
These two functions are convenient in constructing payment schedules or
financial time series.
Examples:
EDATE(TODAY(),3) returns today’s day in 3 months’ time;
EDATE(“29 Jul 06”,3) returns 29 Oct 2006;
EDATE(“29 Jul 06”,-1) returns 29 Jun 2006;
EOMONTH(TODAY(),0) returns the last day of the current month;
EOMONTH((“29 Jul 06”,13) returns 31 Aug 2007;
EOMONTH((“29 Jul 06”,-3) returns 30 Apr 2006.
Date-related functions
The DATE(year, month, day) function provides a more general approach to
manipulate dates in Excel. It can be used in conjunction with the YEAR(),
MONTH(), and DAY() functions to develop more complex functions such as the
EDATE() and EOMONTH() functions discussed above.
DATE(2006,7,11) returns the date serial number for 11 July 2006;
YEAR(“11 Jul 06”) or YEAR(DATE(2006,7,11)) returns 2006;
MONTH(“11 Jul 06”) or MONTH(DATE(2006,7,11)) returns 7;
DAY(“11 Jul 06”) or DAY(DATE(2006,7,11)) returns 11;
DATE(YEAR(TODAY()),MONTH(TODAY())+1, DAY(TODAY())) returns 11 Aug 2006.
Exercise 6
Logical functions
OR(logical1, [logical2], …) function returns either the logical value TRUE
or FALSE. If any condition inside OR( ) function is TRUE, it returns TRUE. If
all the conditions inside OR( ) function is false, it returns FALSE.
Example:
To test if the value in A1 OR the value in B1 is greater than 50 (=OR(A1>50,
B1>50))
Logical OR
False OR false = ?
False OR true = ?
True OR false = ?
True OR true = ?
Logical functions
(1=1 AND 2=2) = ?
(1=1 AND 1=2) = ?
(1=1 OR 1=2) = ?
(1=1 OR 1=2 OR 3=3 OR 4=4) = ?
(1=1 AND 1=2 AND 3=3 AND 4=4) = ?
(1=1 AND (2=2 OR 1=2)) = ?
(1=1 AND ((2=2 AND 3=3) OR (1=3 OR 1=2)) = ?
NOT(1=1 AND ((1=3 OR 1=1) AND (1=3 AND 1=2)) = ?
Exercise 8
Table lookup functions
VLOOKUP(lookup_value, table_range, return_column, [match_type])
looks up data in a table organized vertically.
Lookup values must appear in the first column of the table passed into
VLOOKUP
Example:
Suppose we have a list of dates in ’A1:A200’ and the corresponding daily
closing prices of a particular stock in ‘B1:B200’, the VLOOKUP() function can
be used to extract the closing prices for some specified dates, say, in
‘C1:C10’. VLOOKUP(C1,$A$1:$B$200,2,0) returns the closing price
corresponding to the date in C1.
Note that if an approximate match is specified (value 1 or true for match
type), the data table must be sorted in an ascending order, and the largest
value that is less than the specified lookup value is returned if an exact
match (value 0 or false for match type), is not found.
Exercise 9 (A) and (B)
Table lookup functions
HLOOKUP(lookup_value, table_range, return_row,
[match_type]) function works in a similar fashion for a
data table that has a horizontal orientation.
Lookup values appear in the first row of the table
Similar to VLOOKUP( ) function, HLOOKUP( ) supports
approximate and exact matching.
Exercise 9(C)
Table lookup functions
INDEX(array, row_number, column_number) returns the
value at a given position in a range or array. It extracts the
value from a specified row and column in a worksheet range
or data table.
Example: If the data range is in $A$1:$D$100,
INDEX($A$1:$D$100, 5, 4) returns the value contained in the
Cell D5 (i.e. the cell in the 5th row and the 4th column of
the data range).
The INDEX() function alone is not helpful since we generally
do not know the location (row and column numbers) of the
target value in the data table. However, we can use the
Excel MATCH() function in conjunction with the INDEX()
function to locate the target value.
Table lookup functions
MATCH(lookup_array, row_ or column_range, [match_type])
returns the position of the matched ‘value’ within a ‘row or
column range’.
If ‘match type’ is set to 0, Excel looks for an exact match.
Values in the row or column can be unsorted in this case.
If ‘match type’ is set to 1 (default value), Excel looks for an
approximate match (next smallest). MATCH() returns the position
of the largest value in the range that is less than or equal to the
specific value. In this case, values in the comparison range must be
sorted in an ascending order.
Exercise 10(A)
Table lookup functions
Consider a dataset such as the one below:
Suppose that the dates are in a column range named ‘dates’ and the
stock codes are in a row range named ‘codes’. The prices are in a
range named ‘data’. (To assign a name to any worksheet range, simply
select the range to be named and type the name in the ‘name box’
next to the ‘formula bar’. The following formula returns the stock
price ($9.4) for XYZ on 1 Oct 2005:
=Index(data, match(date(2005,10,1),dates,0), match(“xyz”,codes,0))
See Exercise 10(B)
Table lookup functions
OFFSET(start_range, row_offset, column_offset, [row_size],
[col_size]) returns a range with a dimension of ‘row_size’ rows by
‘col_size’ columns.
The returned range will start at ‘row_offset’ number of rows and
‘column_offset’ number of columns away from the start of the ‘start
range’ often known as reference cell/range.
The ‘start_range’ can be a single cell, in which case the returned
range is also a single cell when the last two arguments in the function
are omitted.
Note: If ‘row_size’ and ‘col_size’ are omitted, the returned range will
have the same dimension at the ‘start_range’.
Table lookup functions
Examples:
OFFSET(A1, 1, 2) returns the value in C2
OFFSET(A1, 1, 2, 1, 2) returns the value in C2:D2
OFFSET(B2, -1, -1) returns the value in A1
OFFSET(A1:B2, 1, 1) returns the value in B2:C3
OFFSET(A1, 1, 1, 2, 2) returns the value in B2:C3
Note: press Ctrl + Shift + Enter to generate multiple results (in the
selected range)
Table lookup functions