Sub GhiSo()
Dim i As Long, j As Byte, Max As Byte, No, Co
S4.Activate
On Error Resume Next
No = Split([J7], "-")
Co = Split([j8], "-")
Max = IIf(UBound(No) > UBound(Co), UBound(No), UBound(Co))
i = S2.[A65536].End(xlUp).Row + 1
With S2
.Range("A" & i) = [D5]
.Range("B" & i) = [J6] 'dong nay phai sua ntn de no cap nhat duoc ca PT...(Vi du: PT 1, PT 2, ...)
.Range("C" & i) = [D5]
.Range("D" & i) = [B8] & " - " & [G11]
.Range("F" & i, "G" & i) = Application.WorksheetFunction.Transpose([J7:J8])
.Range("A" & i).Resize(, 8).Copy .Range("A" & i).Resize(Max + 1)
If UBound(No) > UBound(Co) Then
For j = 0 To UBound(No)
.Range("F" & i + j) = No(j)
.Range("H" & i + j).Resize(, 2) = [K7].Offset(j)
Next j
Else
For j = 0 To UBound(Co)
.Range("G" & i + j) = Co(j)
.Range("H" & i + j).Resize(, 2) = IIf(Max = 0, [B9], [K7].Offset(j))
Next j
End If
End With
S4.Range("D5,C6,B7:B9,B11,G11,J7:J8").ClearContents
End Sub