I have been trying to get this to work for a good part of a week, but am limited in my knowledge of VBA syntax so nothing I’ve been able to find has worked. Please help.
I have 4 workbooks. “Template”, “Process”, “CR” and “DQM” each having one sheet named the same as the workbook (except the Template one). The “Template” workbook is my destination workbook with the other 3 being source workbooks with variable row and column data. I have code in “Template” that loops through the data in “Process” and creates a “NewSheet” in “Template” for each value in “IDColumn” in “Process” and names the sheet with that value and populates some data on the “New Sheet”. Works beautiful.
Within the loop “i” that creates the sheets, I need to extract only rows from the “CR” workbook, where the “SORID” column contains (partial text) that matches the value for the “NewSheet” in the “Template” workbook. The value I need to match on also gets populated on each “NewSheet” in cell “B4”. All matching rows in the “CR” source workbook should then get populated on rows on the matching “NewSheet” starting in cell “E5”. I do not want it to copy/paste, just populate the data. (Note: I have populated other data with out copy/paste by using code similar to: WB1.WS1.Range.Value = WB2.WS2.RAnge.Value so I know it can be done and it is very fast.)
Once that is done, I need to do the same thing with the “DQM” workbook data as I did with the “CR” data, but it should populate 5 rows down from the last row of “CR” data, still starting in Column E. I will also need to create a header for the DQM data that is 3 rows done from the last row of the CR data and will populate column headers on row beneath DQM Header. One difference is i don’t need to populate columns A and B in the destination worksheets, so extracting only part of each matching row.
CR Source Data
enter image description here
DQM Source Data
enter image description here
Template Final Result
Sheet 123456: enter image description here
Sheet 234567: enter image description here
Sheet 345678: enter image description here
I have spreadsheets I can attach if someone can direct me how to do it.
I have tried variations using “InStr” and “.value=.value” type of code. I have found bits and pieces of how to accomplish this, but am not experienced enough to tweak it to make it work for me and most were using a copy/paste scenario which I definitely do not want.
Please add comments to lines of code so I know what it is doing so I can learn. Thank you very much for any assistance!
Shawn-rika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.