Hey,
I'm trying to edit the following VBA code so that the file I open becomes variable:
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
For some reason, I keep getting an error when I attempt to run. I also need to incorporate a loop at some point so that it runs for all twelve months.
A2:D2 are just January; Jan; 2011; 11
Thanks in advance.
I'm trying to edit the following VBA code so that the file I open becomes variable:
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
For some reason, I keep getting an error when I attempt to run. I also need to incorporate a loop at some point so that it runs for all twelve months.
A2:D2 are just January; Jan; 2011; 11
Thanks in advance.