Sub test()
Dim ar, br, r, i, k
k = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
With Sheet1.Sort
.SortFields.Add Key:=Sheet1.Range("B2:B" & k)
.SortFields.Add Key:=Sheet1.Range("J2:J" & k)
.SortFields.Add Key:=Sheet1.Range("K2:K" & k)
.SetRange Range("A1:T" & k)
.Header = xlYes
.Apply
End With
ar = Sheet1.[a1].CurrentRegion
br = Sheet2.Range("A1:X" & k)
Set r = CreateObject("vbscript.regexp")
r.Pattern = "\x5b.+\x5d|\x28.+\x29|SQ|AWG|1X"
r.Global = True
For i = 2 To k
br(i, 1) = Split(ar(i, 19), "-")(0)
br(i, 2) = Format(Split(ar(i, 19), "-")(1), "00000")
br(i, 6) = ar(i, 15)
br(i, 17) = Int(ar(i, 11))
br(i, 18) = ar(i, 3)
br(i, 19) = Left(ar(i, 3), 4) + 1 & Right(ar(i, 3), 4)
br(i, 21) = Right(ar(i, 2), 2) & " " & r.Replace(ar(i, 10), "")
br(i, 24) = Right(ar(i, 2), 2)
Next i
Sheet2.Range("X2:X" & k).NumberFormatLocal = "@"
Sheet2.[a1].Resize(k, 24) = br
End Sub |