G
Guest
I can't get my brain around this and need some help on what direction to go. I am using Excel2002 and windowsXP. Here is what I have
Sub CreateIDFiles(
Application.ScreenUpdating = Fals
Application.DisplayAlerts = Fals
Dim CreateFiles As Strin
Dim sh As Workshee
Dim i As Lon
Dim cLastRow As Lon
Sheets("IDList").Selec
Set sh = ActiveWorkbook.ActiveShee
cLastRow = Cells(Rows.Count, "B").End(xlUp).Ro
For i = 1 To cLastRo
CreateFiles Left(sh.Cells(i, "B").Value, Len(sh.Cells(i, "B").Value) -0
Next
End Su
Sub CreateFiles(FileName As String
Dim TestStr As Strin
If Dir(ThisWorkbook.Path & "\ProgramData\FileData\StoredData\IndividualReports\" & FileName & ".xls") = "" The
Workbooks.Ad
Sheets("Sheet2").Selec
ActiveWindow.SelectedSheets.Delet
Sheets("Sheet3").Selec
ActiveWindow.SelectedSheets.Delet
ActiveWorkbook.SaveAs (ThisWorkbook.Path & "\ProgramData\FileData\StoredData\IndividualReports\" & FileName & ".xls"
Els
Workbooks.Open (ThisWorkbook.Path & "\ProgramData\FileData\StoredData\IndividualReports\" & FileName & ".xls"
End I
'!!!!!HERE IS WHERE I AM LOST!!!
End Su
What this does is go through a list of ID's and either makes a file that is named the same as the ID or it opens the file if it already exists. All of that works fine. Then what I need to do for each of these books is while it is opened, go look in two different folders, open any workbook that is in them (may be one or several), and then copy any data out of each of those into this first workbook that was either opened or created.
I know how to do the search for data by the ID for data and copy the row into this new workbook, what I don't know how to do is open the workbooks that have the data. I am thinking I can use almost this same macro with slight additions to find and open those files to copy data out of them, but I am just a little lost as to how to do this
Any help on what direction to go for this would be great, I think I can handle the code and the code for the copy and paste part, I just don't know how to get the files open and selected to copy the data
Thanks
Jim
Sub CreateIDFiles(
Application.ScreenUpdating = Fals
Application.DisplayAlerts = Fals
Dim CreateFiles As Strin
Dim sh As Workshee
Dim i As Lon
Dim cLastRow As Lon
Sheets("IDList").Selec
Set sh = ActiveWorkbook.ActiveShee
cLastRow = Cells(Rows.Count, "B").End(xlUp).Ro
For i = 1 To cLastRo
CreateFiles Left(sh.Cells(i, "B").Value, Len(sh.Cells(i, "B").Value) -0
Next
End Su
Sub CreateFiles(FileName As String
Dim TestStr As Strin
If Dir(ThisWorkbook.Path & "\ProgramData\FileData\StoredData\IndividualReports\" & FileName & ".xls") = "" The
Workbooks.Ad
Sheets("Sheet2").Selec
ActiveWindow.SelectedSheets.Delet
Sheets("Sheet3").Selec
ActiveWindow.SelectedSheets.Delet
ActiveWorkbook.SaveAs (ThisWorkbook.Path & "\ProgramData\FileData\StoredData\IndividualReports\" & FileName & ".xls"
Els
Workbooks.Open (ThisWorkbook.Path & "\ProgramData\FileData\StoredData\IndividualReports\" & FileName & ".xls"
End I
'!!!!!HERE IS WHERE I AM LOST!!!
End Su
What this does is go through a list of ID's and either makes a file that is named the same as the ID or it opens the file if it already exists. All of that works fine. Then what I need to do for each of these books is while it is opened, go look in two different folders, open any workbook that is in them (may be one or several), and then copy any data out of each of those into this first workbook that was either opened or created.
I know how to do the search for data by the ID for data and copy the row into this new workbook, what I don't know how to do is open the workbooks that have the data. I am thinking I can use almost this same macro with slight additions to find and open those files to copy data out of them, but I am just a little lost as to how to do this
Any help on what direction to go for this would be great, I think I can handle the code and the code for the copy and paste part, I just don't know how to get the files open and selected to copy the data
Thanks
Jim