Ok, code inconsistencies...
Know that the primary focus was on the provided "MRP planned purchase orders" provided in posts 2 and 3, I did not refer back to the planned work orders.
The 1st image:
Has a leading space and the Format_Date (which might be redundant) function, which does not match the other.
The $ReportDate is initialized with a space, is there a need to start with two spaces before "Through"?
The 2nd and
3rd images:
1. The right-hand side is because of my item 3 in post #4, about echo reduction.
2. I added the non-breaking space between the empty <th></th> tags, likely out of habit, and probably not necessarily required.
(there have been reasons why I've done this in the past, but I cannot cite any specific example at the moment)
Update:
I have recalled why now on the non-breaking space in empty table cells: ...from past dealings with empty table cells that did not render their borders if the content was empty and/or any CSS/styling would not get applied to empty table cells. From what I recall, the behavior seem to occur with both <th> and <td> cells, as these would appear as a 'blank squares' within the rows of a table.
It seems that I am not alone with that habit based on
this older stackoverflow topic, and here's an
explanation of the behavior from 2013. Newer browsers may no longer have this behavior/trouble, and there is apparently CSS alternatives to the situation now, as mentioned in both links. Going forward, it seems that I need to break this habit!
The 4th image:
Yes, that should likely be applied to the other file. I happened to note while applying your code, the potential for an empty (missing) cell, as there are 9 columns. The 9th column cell (Consolidation info) is only added when the condition is true, but no cell when false, which would leave 8 cells instead of 9.
The 5th image:
Same thing concerning "echo reduction"
No worries! Most of these should get matched since the "other" file will also need the cell addition, I can apply the same at that time.