Mã:
Option Explicit
Public Sub GPE()
Dim sArr, dArr, I As Long, K As Long, Ma As String, MaTen As String, Ten As String
sArr = Sheet1.Range("A4", Sheet1.Range("A65000").End(3)).Resize(, 3).Value
ReDim dArr(1 To UBound(sArr), 1 To 5)
For I = 1 To UBound(sArr)
If InStr(1, sArr(I, 1), "|", 1) Then
Ma = Mid(sArr(I, 1), 1, InStr(1, sArr(I, 1), "|", 1) - 2)
MaTen = Mid(sArr(I, 1), 14, InStr(1, sArr(I, 1), "-", 1) - 15)
Ten = Mid(sArr(I, 1), InStr(1, sArr(I, 1), "-", 1) + 2, Len(sArr(I, 1)))
Else
If sArr(I, 2) <> Empty Then
K = K + 1
dArr(K, 1) = Ma
dArr(K, 2) = MaTen
dArr(K, 3) = Ten
dArr(K, 4) = sArr(I, 2)
dArr(K, 5) = sArr(I, 3)
End If
End If
Next I
With Sheet2
.Range("A3:E1000").ClearContents
.Range("A3").Resize(K, 5) = dArr
End With
End Sub