A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
ExcelFunTension,
As per my previous post, I have created an additional worksheet called "Unique List" in the Macro code workbook. The code actually copies the first 2 columns from the Source data to this worksheet. Then the duplicates are removed based on only the first column and leaving a unique list in the first column and the associated description in the second column. (I assumed that the description is the same for all same numbers in the first column so I hope this assumption is correct).
Code has been modified to reflect the above.
NOTE: I modified the source records with additional dummy data and Unique Numbers to provide additional data for testing. I also modified the code for the specific columns of data to copy because the code example you provided was copying columns of data that I didn't have.
Note where I have copied the columns that I am now using the table column name in lieu of the column number (It makes it self documenting and you don't have to count up the columns. If any fail then probably due to a leading or trailing space on the column header in the table (I actually had one of these).
The Unique list remains after the code has run if you wish to view it. Also, the code activates the sheet when finished.
I still don't understand where the number comes from for cell B1 on Coversheet. Cells B3 and B4 are populated from the table created in worksheet "Unique List" in the Macro workbook.
To find the code to populate above 2 cells
- Click anywhere in the sub
- Select Menu Item Edit -> Find and in "Find what" enter Coversheet and click "Find Next".
- You should find the following code that populates the cells B3 and B4 and also creates the FileName from the values.
'Populate Output CoverSheet with Unique Number and Description from the Unique List in the Unique List sheet
With wbOutput.Worksheets("Coversheet")
.Cells(3, "B") = rngUniqVal.Value 'Unique Number
.Cells(4, "B") = rngUniqVal.Offset(0, 1).Value 'Description
.Range("B3:B4").HorizontalAlignment = xlLeft 'Left justify in case one or both of the values are numeric
'Create the New FileName from the Unique Number and Description
strFileName = .Cells(3, "B").Value & " " & .Cells(4, "B").Value
End With
I have uploaded the edited workbooks to the following link: Link to zipped files