About Unique number yes it is unique after removing the duplicates. For input box the unique number is the query number to filter the table. Same goes in the coversheet e.g MCR-Unique number-002
Column A in wsSource is the unique number after removing the duplicates.
If I adjust the zoom in template it replicates I tested it.
In the below code
For Each rngUniqVal In rngUnique
wbMacro.Sheets(2).Copy
Set wbOutput = ActiveWorkbook
With wbMacro
For s = 3 To .Worksheets.Count
.Worksheets(s).Copy After:=wbOutput.Worksheets(wbOutput.Worksheets.Count)
Next s
End With
Set wsOutput = wbOutput.Sheets("Output")
With wsOutput
lngLastRow = LastRow(.Cells)
If lngLastRow < 4 Then lngLastRow = 4
.Range(.Rows(4), .Rows(lngLastRow)).ClearContents
End With
wbMacro.Sheets(2).Copy
The above code will automatically create a new workbook? from the code I see cover sheet is being copied then workbooks.add and paste is required I was hoping.
.Range(.Rows(4), .Rows(lngLastRow)).ClearContents
wsOutput has no data yet why clear contents was used.
if LastRow(.Cells) = 4
Then Range(4, 4) .ClearContents I did not understand it.
I am thinking of altering the code for creating the Unique list( duplicates removed). Instead of using a temporary worksheet, it will be better if I add a sheet to the Macro workbook and simply clear the list for each new run of the code.
I actually expected the same that might be useful for documentation or to check for how many unique numbers the workbooks were created. I saw the code creates wsTemp and deletes at the end. That is also good leaves no remnants or new sheets.
Now I realized when I uploaded the workbooks they had the previous code in them that I should have deleted before uploading. That code is no good to run on the sample dataset.