0% found this document useful (0 votes)
49 views4 pages

Financial Programming and Data Analysis I - Vba - : MSC in Finance

This document outlines 10 exercises for a financial programming and data analysis course focusing on VBA macros and functions. The exercises involve writing macros and functions to: 1) Calculate product bills based on inputted sale price, units, and VAT rate 2) Greet a user and check their age based on inputted name and age 3) Calculate printing bills based on inputted copy numbers and pricing tiers 4) Display numbers around an inputted number 5) Calculate net present value of a project based on discount rate and cash flows 6) Price options using the Black-Scholes formula via a VBA function
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views4 pages

Financial Programming and Data Analysis I - Vba - : MSC in Finance

This document outlines 10 exercises for a financial programming and data analysis course focusing on VBA macros and functions. The exercises involve writing macros and functions to: 1) Calculate product bills based on inputted sale price, units, and VAT rate 2) Greet a user and check their age based on inputted name and age 3) Calculate printing bills based on inputted copy numbers and pricing tiers 4) Display numbers around an inputted number 5) Calculate net present value of a project based on discount rate and cash flows 6) Price options using the Black-Scholes formula via a VBA function
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Financial Programming and Data Analysis I

- VBA -
MSc in Finance
Exercise sheet

Exercise 1:
Using InputBox, write a macro that asks a seller the sale the pre-tax price of a product, the
number of units sold and the VAT rate and returns the bill. Then, write a function that
returns the bill amount.

Exercise 2:
Using InputBox, write a program that takes a name as argument and returns the string
“Hello” name “!”. Then the program asks “How old are you?”. If the user enters a number
less than 18, the program returns “Parental advisory requested”. If the number is equal to or
above 18, the program returns “Parental advisory not requested”. If the syntax is invalid, the
program returns “Invalid answer” and the box “How old are you?” appears again (and so on).

Exercise 3:
A store has the following pricing rule:
 0.10$ for the first ten copies
 0.09$ for the next twenty copies
 0.08$ for the next copies.
1. Write a macro that asks, through InputBox, the user to enter the number of copies
printed and returns the bills accordingly.
2. Redo the same exercise but instead of using InputBox, create a function (ex.:
Mybill(…)) that returns the bills. Call the function under excel and test it for a large
range of copy number.
Exercise 4:
With InputBox, write a macro that asks the user to enter a number. Then the algorithm
displays the five numbers that precedes the number and the ten next numbers too.
Dim nb as Integer
Dim vect(1 to 5) as string
Dim vect(1 to 10) as string
Nb = inputbox (“enter a number”)
For i = 1 to 5
Vect(i) = nb - 1
Nb = nb – 1
MsgBx (number -1)

Exercise 6:
If you have used the while (for) loop in the previous exercise, do it again using the for (while)
loop instead.

Exercise 7:
Write a function that computes the NPV of a project, given a discounted rate, an initial
investment and a stream of future cash flows.
Example:
 Disc_r = 0.0005
 I_0 = 100000
 CF_stream = [10000,15000,20000,40000]
 You create: My_NPV_Function(Disc_r, I_0, CF_stream)
 Test it under Excel

Dim Disc_r as integer


Dim I_0 as integer
Dim CF_stream as range
Disc_r = 0.0005
I_0 = = 100000
CF_stream = [10000,15000,20000,40000]
My_NPV_Function(Disc_r, I_0, CF_stream)
Begin
For i = 1 to 4
S = sum CF_steam i / (1+Disc_r)^i
My_NPV_Function(Disc_r, I_0, CF_stream) = S - I_0
End

Dim N as Integer
N = WorksheetFunction.Count(CF_steam)
Dim Sum_Disc_CF As Single
Sum_Disc_CF = 0
For i = 1 to N
Sum_Disc_CF = Sum_Disc_CF + CF_steam (i) / (1+Disc_r)^i
Next i

Remark: The cash flows could be numbers aligned in one single excel column/line.

Exercice 8:
Exercise 7 with all arguments exhibited on a excel spreadsheet. A control button generates
the NPV.

More advanced:
Exercise 9:
Price an option with the Black and Scholes formula on a non-dividend paying stock. To do so,
create a VBA function.
Optional: Use the approximation provided by Hull (2002) for the normal CDF.

Exercice 10:
Exercise 9 with the parameters shown on a excel spreadsheet. The Black and Scholes value is
generated with a control button.

You might also like