Assignment 3

advertisement
Assignment 3. Financial Calculations and Data Tables
Overview. Build a workbook to write an Excel user defined function and demonstrate how it
may be used to do calculations involving one- and two-way Data Tables. As with your first
assignment, you must complete this one without help from anyone else, including classmates,
friends, teachers, etc., as the grading of the assignment makes the assumption that you have
completed it without assistance from others.
1. Write a user defined function to calculate the present value of a growing finite annuity.
Name the function PVAG. The arguments should be C, g, r, and n (in that order) as
described on page 18 of your text. The function should be capable of computing a value
for any reasonable set of inputs, including the special case where r = g.
For help on creating functions you may wish to check the web. Here is one useful site:
http://www.wikihow.com/Create-a-User-Defined-Function-in-Microsoft-Excel
You will not need to declare additional variables in this function but if you were to use them you
need to declare them and specify their type. See the link and table below for variable types:
https://support.microsoft.com/en-us/kb/843144
Data
type
Boolean
Integer
Long
Double
Storage size Allowable Range
2 bytes
2 bytes
4 bytes
8 bytes
True or False
-32,768 to 32,767
-2,147,483,648 to 2,147,483,647
-1.79769313486232E308 to -4.94065645841247E-324 for negative
values; 4.94065645841247E-324 to 1.79769313486232E308 for
positive values
-922,337,203,685,477.5808 to 922,337,203,685,477.5807
January 1, 100 to December 31, 9999
Currency 8 bytes
Date
8 bytes
10 bytes +
String
string length
Example function:
Function PVAG(c, r, g, n)
Dim j, k As Integer
Dim A(10, 20) As Long
'Double loop to initialize array A
For k = 1 To n
For j = 1 To n
A(j, k) = j + 0.1 * k
Next j
Next k
'End double loop
'Bogus calculation for PVAG function:
PVAG = c + r + g + n
If r = g Then
PVAG = c + n
End If
GoTo 22
22 PVAG = PVAG + 1
End Function
Be sure to document your function copiously and accurately to explain what it does,
what the input parameters are, and what key sections of the VBA code do.
2. Build a one-way Data Table to demonstrate use of the new PVAG function. The example
should be unique and one of your choosing. The values calculated in the body of the
Table should reflect different parameter input values. The Table should be on the first
sheet named Table1. The Table should be approximately ten rows deep and contain at
least three output variables (the columns). Be sure the documentation is precise and
sufficient to explain the example. Use good programming conventions discussed in class
where possible.
3. Similarly, build a two-way Data Table to demonstrate use of the new PVAG function.
This should be a different example than the one-way table. The Table should be
approximately 10 by 10 on the second sheet named Table2.
4. Be sure to document (label and explain) both sheets and the special function. Use blue
font for all input cells (cells whose values the user may change and still produce correct
output values).
5. Be sure that you have named the workbook with your class number and last name (ex.
04James.xlsm). Save it on your class flash drive with a backup copy in the Backup folder
as you did for the first assignment. Note that late assignments may be accepted with a
grade penalty.
6. Grading of this assignment will consider:
a. Degree and accuracy of documentation of both sheets and function
b. Uniqueness and complexity of Table examples
c. Accuracy of calculations
d. Formatting of sheets (they should be clear, neat and readable)
e. Following instructions
Download