Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

P.

879, IfElself Statements


Function Block If (Parameter)
If Parameter <0, Then
if parameter = -3
Block IF= -1
ElseIf Parameter =0 Then
Block If =0
Else
Block If=1
End If
End Function
Function BlockIf
(Parameter)

Function Name input variable name

Financial Modelling
Function NestedIf (P1,P2)
If P1 >10 Then
If P2>5 Then
Nested If=1
Else
Nested If=2
End If
ElseIf P1<-10 Then
If P2 >5
Page 882 Select Case Statement
Function Simple Select (Parameter)
Select Case Parameter
Case1
SimpleSelect =111
Case2
Simple Select=222
Case 3,5,6
Simple Select= 333
Case 4, 2
Simple Select =444
Case Else
Simple Select = 555
Case Else
Simple Select=555
End Select
Page 836 Factorial Function
Function HomeFactorial (N)
If Int(N) <> (not equal) N Then Integral condition check
HomeFactorial = CVErr(xlErrValue)
Else If N<0 Then

HomeFactorial= CVErr(xlErrNum)
Else If N=0 Then
HomeFactorial =1 Base Case is important!
Else
HomeFactorial = Home Factorial (N-1) * N Recursion process
End if
End function
Eg. Home Factorial (3) N=3
Home Factorial (3)= Home Factorial (2) x3
Home Factorial (2)= Home Factorial (1) x 2
Home Factorial (1)= Home Factorial (0) x 1
Home Factorial (0)=1
1. Base Case
2. Recursive Statement (stop at the base case)

Page 887 Combination


Function HomeCombin (N, x)
HomeCombin = HomeFactorial (N) / (HomeFactorial(N-x) * HomeF
Page 887 Binomial Probability
Function HomeBinom(p,N,x)
If N<0, Then
Home Binom = CVErr(xIErr Value)
Elself x>N or x<0 Then
HomeBinom = CVERR(xlErrNum) Make the unction returns NUM!
Else
HomeBinom = HomeCombin(N,x) * p^ x* (1-p) ^ (N-x)
End If
End Function

You might also like