Professional Documents
Culture Documents
Lecture 001
Lecture 001
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)