M
minjae.sheen
I'm a newbie in VBA, so I might have made a stupid mistake. The
following function procedure worked fine in Excel 2003 at my workplace
but gives a #NAME error in 2007. I appreciate your help.
Also, please comment if you have any recommendation to simplify or
speed up the procedure. Thanks!!
Function Rent(Startmonth As Integer, CurMonth As Integer, RemMonth As
Integer, DT1 As Integer, DT2 As Integer, LeasePrd1 As Integer,
LeasePrd2 As Integer, CurAmount As Currency, AskAmount As Currency,
Inflation As Currency)
Dim i As Integer
For i = 1 To 10
Select Case CurMonth
Case Is <= (Startmonth + RemMonth): Rent = CurAmount
Case Startmonth + RemMonth + DT1 + 1 To _
Startmonth + RemMonth + DT1 + LeasePrd1
Rent = AskAmount * Inflation
Case Startmonth + RemMonth + DT1 + LeasePrd1 + DT2 + 1 To _
Startmonth + RemMonth + DT1 + LeasePrd1 + DT2 + LeasePrd2
Rent = AskAmount * Inflation
Case Startmonth + RemMonth + DT1 + LeasePrd1 + DT2 * (i + 1) +
LeasePrd2 * i + 1 To _
Startmonth + RemMonth + DT1 + LeasePrd1 + (DT2 + LeasePrd2) *
(i + 1)
Rent = AskAmount * Inflation
End Select
Next i
End Function
following function procedure worked fine in Excel 2003 at my workplace
but gives a #NAME error in 2007. I appreciate your help.
Also, please comment if you have any recommendation to simplify or
speed up the procedure. Thanks!!
Function Rent(Startmonth As Integer, CurMonth As Integer, RemMonth As
Integer, DT1 As Integer, DT2 As Integer, LeasePrd1 As Integer,
LeasePrd2 As Integer, CurAmount As Currency, AskAmount As Currency,
Inflation As Currency)
Dim i As Integer
For i = 1 To 10
Select Case CurMonth
Case Is <= (Startmonth + RemMonth): Rent = CurAmount
Case Startmonth + RemMonth + DT1 + 1 To _
Startmonth + RemMonth + DT1 + LeasePrd1
Rent = AskAmount * Inflation
Case Startmonth + RemMonth + DT1 + LeasePrd1 + DT2 + 1 To _
Startmonth + RemMonth + DT1 + LeasePrd1 + DT2 + LeasePrd2
Rent = AskAmount * Inflation
Case Startmonth + RemMonth + DT1 + LeasePrd1 + DT2 * (i + 1) +
LeasePrd2 * i + 1 To _
Startmonth + RemMonth + DT1 + LeasePrd1 + (DT2 + LeasePrd2) *
(i + 1)
Rent = AskAmount * Inflation
End Select
Next i
End Function