Hi there,
I have a problem with my code and I have no idea why the code does not reset.
The MainMenu of the code is as follows:
Public reff(0 To 8) As String
Sub MainMenu()
Dim p As Integer
CurrentYE = #12/31/2008#
reff(0) = "01001060000123"
reff(1) = "01390080000253"
reff(2) = "01283080000222"
reff(3) = "01063080000262"
reff(4) = "01001060000102"
reff(5) = "01063080000261"
reff(6) = "01283080000212"
reff(7) = "00001008994121"
reff(8) = "01063070000384"
Call STOREREF_Mod
Call STORERATE_Mod
On Error GoTo errorhandler
For p = 0 To 8
RefNo = reff(p)
MLR = 0
EIR = 0
Erase TotalRepayment, TotalRepaymentB, RatesName, Rates, FixedRate, StepStartDate, StepEndDate, BillStartDate, BillStartDateB, _
BillEndDate, BillEndDateB, MaturityType, CashFlow_Value, EIR_Value, NumPmt, NumPmtB, PmtMtd, PmtMtdB, RatesDecimal, amortsch
Call GetRowNo_Mod
Call GetMLR_Mod
Call GetDates_Pmt_Mod
Call GetRates_Mod
Call GetPrincipal_Mod
Call GetPeriods_Mod
Call PopDates_Mod
Call PopPeriods_Mod
If CORPbillRowB > 0 Then
If RateType = "DL" Or RateType = "FR" Then
Call PopPayments_B_Series_DL_FR_Mod
ElseIf RateType = "WT" Then
Call PopPayments_WT_Mod
End If
Else
If RateType = "DL" Or RateType = "FR" Then
Call PopPayments_DL_FR_Mod
ElseIf RateType = "WT" Then
Call PopPayments_WT_Mod
End If
End If
Call CalcEIR_Mod
Call PopCV_Mod
If CORPbillRowB > 0 Then
If RateType = "DL" Or RateType = "FR" Then
Call DisplayBSeries_Mod
End If
Else
If RateType = "DL" Or RateType = "FR" Then
Call DisplayNonTier_Mod
ElseIf RateType = "WT" Then
Call DisplayTier_Mod
End If
End If
Sheets("CORP").Select
Cells(1 + p, 22) = EIR
Cells(1 + p, 23) = amortsch(12).CVadj
Cells(1 + p, 24) = amortsch(i).CVadj
Next p
Exit Sub
errorhandler:
Debug.Print "A" & p
Resume Next
End Sub
Basically the problem is this:
When I declare RefNo = reff(manual input a number from 1 to 8), i.e. running the entire macro one at a time, I get my desired result. However when I use try to loop the entire macro (using the For Next loop) to work on 9 different types of data, the code returns the correct data for the first 2 and then doesn't run properly for the rest. I know the fault does not lie with the data because when I manually key in the number, ie declare RefNo = reff(manual input number from 1 to 8), I am able to get my result.
Can someone explain why it is such? In short, my problem is that the code is able to run for one example at a time, but not all together.
Many thanks in advance!
Bookmarks