vba – Move the data from a master sheet to several sheets according to the unique code and the organization of the output sheets

I have the following code that moves the data of a master sheet to different sheets after grouping them with a unique code in the first column. I need to organize the output in a specific order by referring to another Excel. Someone can help.

Sub parse_data ()

Dim lr so long
Dim ws as a worksheet
Dim vcol, i as integer
So long dim
Dim myarr as variant
Tenuous title as a string
Dim titlerow as a whole
vcol = 1
Set ws = Sheets ("Test Data1")
lr = ws.Cells (ws.Rows.Count, vcol) .End (xlUp) .Row
title = "A1: J1"
titlerow = ws.Range (title) .Cells (1) .Row
icol = ws.Columns.Count
ws.Cells (1, icol) = "Unique"
For i = 2 to lr
In error resume next
If ws.Cells (i, vcol) <> "" And Application.WorksheetFunction.Match (ws.Cells (i, vcol), ws.Columns (icol), 0) = 0 Then
ws.Cells (ws.Rows.Count, icol) .End (xlUp) .Offset (1) = ws.Cells (i, vcol)
It will end if
myarr = Application.WorksheetFunction.Transpose (ws.Columns (icol) .SpecialCells (xlCellTypeConstants))
ws.Columns (icol) .Clear
For i = 2 to UBound (myarr)
ws.Range (title) .AutoFilter field: = vcol, Criteria1: = myarr (i) & ""
If it is not evaluated ("= ISREF (& # 39;" & myarr (i) & "& # 39;! A1)") Then
Sheets.Add (After: = Worksheets (Worksheets.Count)). Name = "BR" & myarr (i) & ""
Leaves (myarr (i) & ""). Move after: = Worksheets (Worksheets.Account)
It will end if
ws.Range ("A" & titlerow & ": A" & lr) .EntireRow.Copy Sheets (myarr (i) & "") .Range ("A1")
Leaves (myarr (i) and ""). Columns.AutoFit
ws.AutoFilterMode = False
End Sub