I asked for help and after a few discussions I feel due to my explaining it incorrectly I made it to complicated. I didn't understand why no one else responded back since this other gentlemen couldn't help so I made this new thread because I thought my old one was void in a sense. I apologize for explaining it in a complicated way but again I am self taught VBA and I don't know the terminology very well.
Here is the old thread just in case it is needed
http://www.excelforum.com/excel-prog...html?p=3139470
The code I have is seen below. The DtRNG1, 2, 3 and Dt1, 2, 3 may not be correct in how i used them. Here is the idea behind what i am attempting to do. I have to roll the entire month of FEB but for each individual day not the month as a whole and what that means is each day has a file named
I:\ACCOUNTING\Jesse - Recon\ALL STATE Rollfoward\14400\14400 ALL STATE DAILY ROLLFOWARD " & Dt1.Text & ".xls
This file name changes with each new day corresponding to the days date in the format of MMDDYY thats Dt1.
Dt2 is the same day's date but in the format of MM/DD/YY
Dt3 is a folder date that changes with the month in the format YYYY-MM
The idea is for me to be able to put on Sheet1 of the workbook in column A a list of all the dates for the month of February in Dt1 format and vice versa in their corresponding format in columns B and C.
Once the data is on Sheet1 that I need, the desire is to have a macro that would insert the data from each list in columns A, B, C into the corresponding Dt1, Dt2, and Dt3 into the macro then run it and rinse and repeat until the data in columns A, B, and C were exhausted or the constants ran out. The issue when the macro is ran it errors and says "Compile error: Invalid Next Control variable reference" pointing to the Next Dt1, 2, 3.
Does anyone know how i can make this work or another way all together to fit the desired solution? It sounds like the other gentlemen had the right idea but gave up on me. Although I am not sure if he did or not. Can anyone else help me figure out how to make this work if possible?
Sub DAILYROLLFORWARD()
'
' DAILYROLLFORWARD Macro
' Macro recorded 4/01/2012'
'===============================================================================================================
Dim DtRNG1 As Range, Dt1 As Range
Dim DtRNG2 As Range, Dt2 As Range
Dim DtRNG3 As Range, Dt3 As Range
Set DtRNG1 = Sheets("Sheet1").Range("A:A").SpecialCells(xlConstants)
Set DtRNG2 = Sheets("Sheet1").Range("B:B").SpecialCells(xlConstants)
Set DtRNG3 = Sheets("Sheet1").Range("C:C").SpecialCells(xlConstants)
For Each Dt1 In DtRNG1
For Each Dt2 In DtRNG2
For Each Dt3 In DtRNG3
'===============================================================================================================
Workbooks.Open Filename:= _
"I:\ACCOUNTING\Jesse - Recon\ALL STATE Rollfoward\14400\14400 ALL STATE DAILY ROLLFOWARD BLANK.xls"
Range("A2").Select
ActiveWorkbook.SaveAs Filename:= _
"I:\ACCOUNTING\Jesse - Recon\ALL STATE Rollfoward\14400\14400 ALL STATE DAILY ROLLFOWARD " & Dt1.Text & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Range("A2").Select
ChDir "I:\ACCOUNTING\Jesse - Recon\CO"
Workbooks.Open Filename:= _
"I:\ACCOUNTING\Jesse - Recon\CO\CO_Earnings_LN_" & Dt2.Text & ".xls"
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("14400 ALL STATE DAILY ROLLFOWARD " & Dt1.Text & ".xls").Activate
Sheets("CO").Select
Range("A2").Select
ActiveSheet.Paste
Range("A2").Select
ActiveWorkbook.Save
ActiveWindow.Close
ChDir "I:\ACCOUNTING\Jesse - Recon\ALL STATE Rollfoward\15136"
Workbooks.Open Filename:= _
"I:\ACCOUNTING\Jesse - Recon\ALL STATE Rollfoward\15136\15136 ALL STATE DAILY ROLLFOWARD BLANK.xls" _
, UpdateLinks:=0
ActiveWorkbook.SaveAs Filename:= _
"I:\ACCOUNTING\Jesse - Recon\ALL STATE Rollfoward\15136\15136 ALL STATE DAILY ROLLFOWARD " & Dt1.Text & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Range("A2").Select
ChDir "I:\ACCOUNTING\Title Pledge\AL Titles\" & Dt3.Text & ""
Workbooks.Open Filename:= _
"I:\ACCOUNTING\Title Pledge\AL Titles\" & Dt3.Text & "\AL_ACP_HeldLoans_Title_" & Dt2.Text & ".xls"
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("15136 ALL STATE DAILY ROLLFOWARD " & Dt1.Text & ".xls").Activate
ActiveSheet.Paste
Next Dt1
Next Dt2
Next Dt3
ActiveWorkbook.Save
ActiveWindow.Close
End Sub
Bookmarks