Hey guys,
I'm trying to use the following code to open a file path name that changes based on month and year, and loops until it has completed the process for 12 months. One row per a month. Right now, the following code doesn't loop, and I receive a "Compile error: Variable not defined".
Excel workbook that it will run in:
<tbody>
</tbody><colgroup><col><col><col><col><col><col><col><col><col></colgroup>
I'm trying to use the following code to open a file path name that changes based on month and year, and loops until it has completed the process for 12 months. One row per a month. Right now, the following code doesn't loop, and I receive a "Compile error: Variable not defined".
Code:
Sub ReinvestmentIncome_Check()
Dim wb As Workbook
Dim Lmonth As Date
Dim Smonth As Date
Dim Yr As Date
Dim Syr As Date
Lmonth = ActiveSheet.Range(A2).Value
Smonth = ActiveSheet.Range(B2).Value
Yr = ActiveSheet.Range(C2).Value
Syr = ActiveSheet.Range(D2).Value
Set wb = Workbooks.Open("J:\CF_NIM\" & Yr & " Fair Value Analysis\Monthly Fair Value Attribution\" & Lmonth & " " & Syr & "\" & Smonth & " " & Syr & " FV Return Estimation & Adj Detail.xls")
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("LC & Float").Select
Windows("Nfloat Attribution History.xlsm").Activate
ActiveCell.FormulaR1C1 = _
"=-'[Feb 11 FV Return Estimation & Adj Detail.xls]LC & Float'!R62C12/10^6"
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=-SUM('[Feb 11 FV Return Estimation & Adj Detail.xls]LC & Float'!R62C12:R142C12)/10^6-RC[-25]"
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub
Excel workbook that it will run in:
Period | Residual | Reinvestment Income | Coupon Income Check | |||||
January | Jan | 2011 | 11 | Jan-11 | 28 | |||
February | Feb | 2011 | 11 | Feb-11 | (6) | |||
March | Mar | 2011 | 11 | Mar-11 | 12 | |||
April | Apr | 2011 | 11 | Apr-11 | 41 | |||
May | May | 2011 | 11 | May-11 | 36 | |||
June | Jun | 2011 | 11 | Jun-11 | 11 | |||
July | Jul | 2011 | 11 | Jul-11 | 18 | |||
August | Aug | 2011 | 11 | Aug-11 | 12 | |||
September | Sep | 2011 | 11 | Sep-11 | 12 | |||
October | Oct | 2011 | 11 | Oct-11 | 33 | |||
November | Nov | 2011 | 11 | Nov-11 | 97 | |||
December | Dec | 2011 | 11 | Dec-11 | 36 |
<tbody>
</tbody><colgroup><col><col><col><col><col><col><col><col><col></colgroup>