-
2 Attachment(s)
Copy data from Unique files into Masterfile all the files in the same folder.
-
1 Attachment(s)
Hi Raghavendra
I think this code will do some of what you want
Code:
Sub Raghavendra2() ' http://www.excelfox.com/forum/showthread.php/2238-Copy-data-from-Unique-files-into-Masterfile-all-the-files-in-the-same-folder
Dim LisWb As Workbook
Set LisWb = ThisWorkbook
Dim Ws2 As Worksheet, Ws1 As Worksheet
Set Ws2 = LisWb.Worksheets.Item(2): Set Ws1 = LisWb.Worksheets.Item(1):
Dim strWb As String: Let strWb = Dir(ThisWorkbook.Path & "\" & "*" & ".xlsx", vbNormal)
Do ' Loop through all .xlsx Files in same Folder as this workbook
Let Ws2.Range("A2:A1000").Value = "=" & "'" & ThisWorkbook.Path & "\[" & strWb & "]Sheet1'!$A2"
Dim Lr As Long
Let Lr = Ws2.Range("A2:A1000").Find(what:=0, after:=Ws2.Range("A2"), LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlNext).Row - 1
' Let Ws2.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Value = "=" & "'" & ThisWorkbook.Path & "\[" & strWb & "]Sheet1'!G2"
' Let Ws2.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Value = Evaluate("=IF(ISERR(" & Ws2.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Address & ")," & """""" & ",IF(" & Ws2.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Address & "=0," & """""" & "," & Ws2.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Address & "))")
' Let Ws2.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").NumberFormat = "d.mmm yy"
Let Ws1.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Value = "=" & "'" & ThisWorkbook.Path & "\[" & strWb & "]Sheet1'!G2"
Let Ws1.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Value = Evaluate("=IF(ISERR(" & Ws1.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Address & ")," & """""" & ",IF(" & Ws1.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Address & "=0," & """""" & "," & Ws1.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").Address & "))")
Let Ws1.Range("G" & Ws2.Range("A2").Value + 1 & ":L" & Ws2.Range("A" & Lr & "").Value + 1 & "").NumberFormat = "d.mmm yy"
Let strWb = Dir
Loop While strWb <> ""
End Sub
_._____________________
Here for example is one of your data worksheets ( "Ravi.xlsx" )
Using Excel 2007 32 bit
| Row\Col |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
1 |
S No |
Item |
Price |
Qty |
Total |
Date Distributed |
Task1 |
Task2 |
Task3 |
Task4 |
Date Tasks Completed |
Date Consolidated |
Comments |
Team Member |
2 |
26 |
A2 |
$ 35.00 |
8 |
$ 280.00 |
17. Mrz 18 |
Done |
N/A |
Done |
N/A |
17. Mrz 18 |
|
|
Ravi |
3 |
27 |
A6 |
$ 78.00 |
63 |
$ 4,914.00 |
17. Mrz 18 |
Done |
N/A |
Done |
N/A |
17. Mrz 18 |
|
|
Ravi |
4 |
28 |
B2 |
$ 11.00 |
47 |
$ 517.00 |
17. Mrz 18 |
N/A |
Done |
N/A |
Done |
17. Mrz 18 |
|
|
Ravi |
5 |
29 |
B6 |
$ 96.00 |
8 |
$ 768.00 |
18. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
6 |
30 |
C2 |
$ 74.00 |
63 |
$ 4,662.00 |
18. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
7 |
31 |
C6 |
$ 365.00 |
47 |
$ 17,155.00 |
20. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
8 |
32 |
D2 |
$ 33.00 |
8 |
$ 264.00 |
20. Mrz 18 |
N/A |
Done |
N/A |
Done |
20. Mrz 18 |
|
|
Ravi |
9 |
33 |
D6 |
$ 55.00 |
63 |
$ 3,465.00 |
22. Mrz 18 |
Done |
N/A |
Done |
N/A |
22. Mrz 18 |
|
|
Ravi |
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Worksheet: Sheet1
Here is the results in the master file for the area near that persons entry
Using Excel 2007 32 bit
| Row\Col |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
O |
25 |
24 |
D4 |
$ 22.00 |
41 |
$ 902.00 |
20. Mrz 18 |
N/A |
Done |
N/A |
Done |
20.Mrz 18 |
|
|
Ramesh |
|
26 |
25 |
D8 |
$ 332.00 |
32 |
$ 10,624.00 |
22. Mrz 18 |
Done |
N/A |
Done |
N/A |
22.Mrz 18 |
|
|
Ramesh |
|
27 |
26 |
A2 |
$ 35.00 |
8 |
$ 280.00 |
17. Mrz 18 |
Done |
N/A |
Done |
N/A |
17.Mrz 18 |
|
|
Ravi |
|
28 |
27 |
A6 |
$ 78.00 |
63 |
$ 4,914.00 |
17. Mrz 18 |
Done |
N/A |
Done |
N/A |
17.Mrz 18 |
|
|
Ravi |
|
29 |
28 |
B2 |
$ 11.00 |
47 |
$ 517.00 |
17. Mrz 18 |
N/A |
Done |
N/A |
Done |
17.Mrz 18 |
|
|
Ravi |
|
30 |
29 |
B6 |
$ 96.00 |
8 |
$ 768.00 |
18. Mrz 18 |
|
|
|
|
|
|
|
Ravi |
|
31 |
30 |
C2 |
$ 74.00 |
63 |
$ 4,662.00 |
18. Mrz 18 |
|
|
|
|
|
|
|
Ravi |
|
32 |
31 |
C6 |
$ 365.00 |
47 |
$ 17,155.00 |
20. Mrz 18 |
|
|
|
|
|
|
|
Ravi |
|
33 |
32 |
D2 |
$ 33.00 |
8 |
$ 264.00 |
20. Mrz 18 |
N/A |
Done |
N/A |
Done |
20.Mrz 18 |
|
|
Ravi |
|
34 |
33 |
D6 |
$ 55.00 |
63 |
$ 3,465.00 |
22. Mrz 18 |
Done |
N/A |
Done |
N/A |
22.Mrz 18 |
|
|
Ravi |
|
35 |
34 |
A9 |
$ 12.00 |
65 |
$ 780.00 |
22. Mrz 18 |
|
|
|
|
|
|
|
Sangeeta |
|
36 |
35 |
B9 |
$ 45.00 |
47 |
$ 2,115.00 |
22. Mrz 18 |
Done |
N/A |
Done |
N/A |
21.Mrz 18 |
|
|
Sangeeta |
|
Worksheet: Sheet1
Here are the full results in the master workbook, "zMaster.xlsm", after running the code with your 5 data files.
http://www.excelfox.com/forum/showth...0571#post10571
The data files should be in the same Folder as the Master File. The code should go in the Master workbook
MasterFileAnd5DataWorkbookFolder.JPG : https://imgur.com/za3oGLi
Attachment 2007
Notes:
_ The code uses the second worksheet column 1 temporarily
_ The data worksheets can be open or closed when the code is run. They are not opened by the code. The data from them is taken whilst they are closed. ( But the code will also work if the data files are open )
_ This code assumes that serial numbers are always continuous. If that was not always the case , then the code would need to be modified
_________________________
I am not 100% clear on excactly what should happen to the date in Cloumn L, and also I am not sure exactly what should be done to the date column in the data worksheets. If you clarify that and need more help I will take another look.
Alan
Ref:
https://www.thespreadsheetguru.com/t...a-given-folder
-
-
Hi Raghavendra,
Quote:
Originally Posted by
RaghavendraPrabhu
...I am sure this will save a lot of problems we are experiencing at our work.
we will have fewer problems thanks to your input and help.
I think often automaton helps keep things in order and correct, which is an extra Bonus to the saving of time which it should also give
_._____________________________________________---
Quote:
Originally Posted by
RaghavendraPrabhu
..The date column L should have the date the macro was run on for the record's data that was copied.
In zMaster.xlsm, again the column L should have the date the records were copied...
I expected It was something like that.
My last code attempt may not be the most efficient as , as far as I know, it is not possible to write information to a closed file, so it would be necessary to open the data files to add the data in column L in the data files anyway.
But for now I will just modify the existing code.
Towards the start of the Looping through the data workbooks the data files are now opened.
The closed workbook references will still work even with the workbook open, so the same data is copied across.
The updated date information is included now in the master Workbook and the data workbooks.
So for example , I ran the latest code today, ( the 24th March ) , using the data files supplied in Post #1
Master Worksheet:
The master worksheet after running the code to merge data into it from the data worksheets, looks like this here:
http://www.excelfox.com/forum/showth...0576#post10576
Data worksheet example, ( For Workbook “Ravi.xlsx” , first worksheet)
Here is the data worksheet Before the code runs
| Row\Col |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
1 |
S No |
Item |
Price |
Qty |
Total |
Date Distributed |
Task1 |
Task2 |
Task3 |
Task4 |
Date Tasks Completed |
Date Consolidated |
Comments |
Team Member |
2 |
26 |
A2 |
$ 35.00 |
8 |
$ 280.00 |
17. Mrz 18 |
Done |
N/A |
Done |
N/A |
17. Mrz 18 |
|
|
Ravi |
3 |
27 |
A6 |
$ 78.00 |
63 |
$ 4,914.00 |
17. Mrz 18 |
Done |
N/A |
Done |
N/A |
17. Mrz 18 |
|
|
Ravi |
4 |
28 |
B2 |
$ 11.00 |
47 |
$ 517.00 |
17. Mrz 18 |
N/A |
Done |
N/A |
Done |
17. Mrz 18 |
|
|
Ravi |
5 |
29 |
B6 |
$ 96.00 |
8 |
$ 768.00 |
18. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
6 |
30 |
C2 |
$ 74.00 |
63 |
$ 4,662.00 |
18. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
7 |
31 |
C6 |
$ 365.00 |
47 |
$ 17,155.00 |
20. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
8 |
32 |
D2 |
$ 33.00 |
8 |
$ 264.00 |
20. Mrz 18 |
N/A |
Done |
N/A |
Done |
20. Mrz 18 |
|
|
Ravi |
9 |
33 |
D6 |
$ 55.00 |
63 |
$ 3,465.00 |
22. Mrz 18 |
Done |
N/A |
Done |
N/A |
22. Mrz 18 |
|
|
Ravi |
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Worksheet: Sheet1
Here the same worksheet After the code has run
| Row\Col |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
1 |
S No |
Item |
Price |
Qty |
Total |
Date Distributed |
Task1 |
Task2 |
Task3 |
Task4 |
Date Tasks Completed |
Date Consolidated |
Comments |
Team Member |
2 |
26 |
A2 |
$ 35.00 |
8 |
$ 280.00 |
17. Mrz 18 |
Done |
N/A |
Done |
N/A |
17. Mrz 18 |
24.Mrz 18 |
|
Ravi |
3 |
27 |
A6 |
$ 78.00 |
63 |
$ 4,914.00 |
17. Mrz 18 |
Done |
N/A |
Done |
N/A |
17. Mrz 18 |
24.Mrz 18 |
|
Ravi |
4 |
28 |
B2 |
$ 11.00 |
47 |
$ 517.00 |
17. Mrz 18 |
N/A |
Done |
N/A |
Done |
17. Mrz 18 |
24.Mrz 18 |
|
Ravi |
5 |
29 |
B6 |
$ 96.00 |
8 |
$ 768.00 |
18. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
6 |
30 |
C2 |
$ 74.00 |
63 |
$ 4,662.00 |
18. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
7 |
31 |
C6 |
$ 365.00 |
47 |
$ 17,155.00 |
20. Mrz 18 |
|
|
|
|
|
|
Need more information |
Ravi |
8 |
32 |
D2 |
$ 33.00 |
8 |
$ 264.00 |
20. Mrz 18 |
N/A |
Done |
N/A |
Done |
20. Mrz 18 |
24.Mrz 18 |
|
Ravi |
9 |
33 |
D6 |
$ 55.00 |
63 |
$ 3,465.00 |
22. Mrz 18 |
Done |
N/A |
Done |
N/A |
22. Mrz 18 |
24.Mrz 18 |
|
Ravi |
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Worksheet: Sheet1
Here the code:
http://www.excelfox.com/forum/showth...0577#post10577
Alan
-
Doc Elstein
Thank you this is what I wanted. But, it is not updating th xMaster the second time. Doing it for once.
Input more new work for members and when clicked the first macro, it is working and updating the unique files.
Once the unique files are completed, this macro is not updating the xMaster second time.
Regards
Raghavendra
Regards
Raghu
-
Hi Raghu, Hi Raghavendra
Sorry I do not understand.
Try to explain carefully what should happen.
If possible show me a Before and then an After
Before : what you have:
After: You do this manually to show me what the code should do
Take your time. I am busy today. From Tomorrow I can look again
Alan
-
2 Attachment(s)
Hi Doc Doc Elstein
Please see the attached files.
It is not working when the macro is run the second time.
No hurry. I am away from work for a week due to Easter etc.
Take your time to fix and thank you for your valuable time and knowledge input.
Regards
Raghavendra
-
Hi Raghavendra
I may be beginning to understand what you want.
But some things are still not clear to me.
I do not know which codes you are running when and to which data is being used when.
You need to carefully explain a full run from start to finish of whatever it is that is being done.
_1) First run of code ( which one?? )
Which data is used.
What are the befores and afters
_2) What do you do now ? Run a different code? Which one
Which data is used.
What are the befores and afters
_3) you now run a code a second time ( which one?? )
Which data is used.
What are the befores and afters
_4) What do you do now ? Run a different code? Which one
Which data is used.
What are the befores and afters
Please remember it is obvious to you what is being done and when and which codes you are using. You know the project well
I am having to try and guess often to which codes you are referring and when.
I do not know what is the typical data structure.
I do not know what might be typical data structure in the future.
I do not know how exactly new data is added.
I do not know the typical sequence of events
That is why I need to see befores and afters for all situations. Otherwise I must guess, and I will probably guess wrong..
A clear explanation of exactly what is happening will also help anyone else to benefit from the Thread in the future.
Every time you refer to a code, name it, so as to avoid confusion.
Explain the exact sequence of events. Give example data for each stage showing exactly what you have before and fill in manually to show what you want the code to produce as the after.
Keep the example data to the minimum. But choose it carefully so that it can be use do demonstrate and check all possible scenarios.
I expect that when I finally know exactly what the requirement is, then I may need to start again from the beginning with a new code or codes.
So please take the time to explain very carefully with examples, and then I will try to do this for you over the next week or so.
Alan
-
3 Attachment(s)
Hi Doc Elstein,
I have sorted out the problem. It is a bit convoluted, but it is working. Please have a look at the code below.
Code:
Option Explicit
Sub BringInAllCompletedData()
Call SortAllFiles
Call LoopThroughDirectory
Call UpdateDateInSheet1ColK
Call UpdateOriginalData
Call ClearSheet1
End Sub
'https://www.mrexcel.com/forum/excel-questions/471802-vba-open-file-run-code-close-save-open-next-file.html
Sub SortAllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
Application.DisplayAlerts = False
folderPath = ActiveWorkbook.Path & "\" 'change to suit
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.xlsx")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
'Call a subroutine here to operate on the just-opened workbook
If filename = "zmaster.xlsm" Then
Exit Sub
Else
Call SortSheet1InAllFiles
End If
filename = Dir
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Sub SortSheet1InAllFiles()
Dim MyFile As String
Dim eRow As Long
Dim RowsConsolidated As Long
Dim LastRow As Long
Dim i As Long
eRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells.Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("K2:K" & eRow) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:N" & eRow)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.Save
Range("A1").Select
ActiveWorkbook.Close
End Sub
'http://www.exceltrainingvideos.com/transfer-data-multiple-workbooks-master-workbook-automatically/
Sub LoopThroughDirectory()
Dim MyFile As String
Dim eRow As Long
Dim LRL As Long
Dim LRK As Long
Dim i As Long
Dim FilePath As String
FilePath = ActiveWorkbook.Path & "\"
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Sheets("Sheet1").Activate
MyFile = Dir(FilePath)
Do While Len(MyFile) > 0
If MyFile = "zmaster.xlsm" Then
Exit Sub
End If
Workbooks.Open (FilePath & MyFile)
LRK = Cells(Rows.Count, 11).End(xlUp).Offset(1, 0).Row 'Column L
LRL = Cells(Rows.Count, 12).End(xlUp).Offset(1, 0).Row 'Column K
For i = LRL To LRK
Range("A" & LRL & " : " & "K" & LRK).Copy
Next
ActiveWorkbook.Close
eRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(eRow, 1), Cells(eRow, 11))
If MyFile = "zmaster.xlsm" Then
Exit Sub
End If
Workbooks.Open (FilePath & MyFile)
For i = LRL To LRK - 1
If Range("L" & i).Value = "" Then
Range("L" & i).Value = Date
Columns("L:L").NumberFormat = "[$-C09]dd-mmm-yy;@"
End If
Next
Range("A1").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
MyFile = Dir
ActiveWorkbook.Save
Loop
Columns("A:D").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A2:A" & eRow) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:D" & eRow)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Sub UpdateDateInSheet1ColK()
Dim eRow As Long
Dim i As Long
Sheets("Sheet1").Activate
eRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
For i = 2 To eRow
If Range("K" & i) <> "" Then
Range("L" & i).Value = Format(Date, "dd/mmm/yyyy")
End If
Next
End Sub
'https://www.youtube.com/watch?v=AzhQ5KiNybk
Sub UpdateOriginalData()
Dim i As Integer
Dim j As Integer
Dim LastRow1 As Integer
Dim LastRow2 As Integer
Dim SNo As Double
LastRow1 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
LastRow2 = Sheets("OriginalData").Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow1
SNo = Sheets("Sheet1").Cells(i, "A").Value
Sheets("OriginalData").Activate
For j = 2 To LastRow2
If Sheets("OriginalData").Cells(j, "A").Value = SNo Then
Sheets("Sheet1").Activate
Sheets("Sheet1").Range(Cells(i, "G"), Cells(i, "L")).Copy
Sheets("OriginalData").Activate
Sheets("OriginalData").Range(Cells(j, "G"), Cells(j, "L")).Select
ActiveSheet.Paste
End If
Next j
Application.CutCopyMode = False
Next i
Sheets("OriginalData").Activate
Cells.Select
ActiveWorkbook.Save
Selection.Columns.AutoFit
Range("A1").Select
End Sub
Sub ClearSheet1()
Dim eRow As Long
Sheets("Sheet1").Activate
eRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Range("A2:O" & eRow).Select
Selection.ClearContents
Selection.Columns.AutoFit
Range("A1").Select
ActiveWorkbook.Save
End Sub
Thank you for all your suggestions and input. What I have done is a long drawn process. Maybe it can be written into one macro.
I will consider this as solved.
Thank you for all your help, time and patience.
Regards
Raghu
-
Hi Raghu,
Thanks for the feedback and sharing your solution.
You have clearly worked hard to solve your problem. Great , well done! :)
I had a quick look through your files. It is still a bit difficult for me to understand what you are doing or wanting to do: I do not know your project so to understand would need a clear explanation from start to finish of what you are doing or wanting to do.
I see lots of codes and files but have no idea which codes and files are used for which and when. I have to work very hard to try to guess what is going on. This will be obvious to you, but without a careful explanation from you it will be impossible for anyone like me to have any idea what is going on.
But you appear to have a solution , so great.
The codes may not be the most efficient, but I think those considerations are less and less relevant for an application like yours as computers get faster and have larger memories etc..
It can be advantageous to have a long drawn out process, as this will be easier for you to follow and modify or de bug in the future. I personally prefer long drawn out codes for those reasons, but that is just my opinion, and I am just a hobby computer user and am not a professional programmer.
I expect you may be doing a lot of unnecessary sorting of data, but I cannot be sure as I do not understand what and when things are to be done.
Good luck with the project, and let us know if you need more help.
But please in future try to explain more clearly in words exactly what is to be done , and when and which data is being used for which code .. etc.. etc… You have supplied some excellent detailed Test data and files. It is a shame more explanations to them were missing: Because an explanation was missing, I still could not use them effectively to give a better solution.
You simply need to write in words the action that you take to produce the files, which codes are run and when etc… You need to understand that for someone that does not know the project details as you do, will need them to be explained carefully.
For someone with little MS Excel VBA experience you have done very well to get your working solution. Well done again.
:)
Alan