Option Explicit
Sub ChuyenDoiDuLieu()
Dim lRow As Long, lChuHo As Long
Dim cRng As Range
Application.ScreenUpdating = False
Columns("C:C").Select: Selection.Insert Shift:=xlToRight
[C1] = "NhanKhau": lRow = [b65500].End(xlUp).Row
Set cRng = Range("A3:A" & lRow).SpecialCells(xlCellTypeConstants, 1)
For lChuHo = 3 To lRow + cRng.Count
If Cells(lChuHo, "A").Value <> "" Then
Cells(lChuHo, "A").EntireRow.Insert
lChuHo = 1 + lChuHo
End If
Next lChuHo
lRow = [b65500].End(xlUp).Row: lChuHo = 2
Do
If lChuHo > lRow Then Exit Do
If Cells(lChuHo + 1, "B") <> "" Then
Set cRng = Cells(lChuHo, "B").End(xlDown)
Range(Cells(lChuHo, "B").Offset(1, 1), Cells(cRng.Row, "B").Offset(1, 1)) _
= Range(Cells(lChuHo, "B"), Cells(cRng.Row, "B")).Value
Range(Cells(lChuHo + 1, "B"), cRng).Value = ""
Range(Cells(lChuHo, "B").Offset(1, 2), cRng.Offset(1, 3)) = _
Range(Cells(lChuHo, "B").Offset(, 2), cRng.Offset(, 3)).Value
Cells(lChuHo, "B").Offset(, 2).Resize(, 2).Value = ""
lChuHo = cRng.Row + 2
Else
Cells(lChuHo + 1, "C") = Cells(lChuHo, "B").Value
Cells(lChuHo + 1, "D").Resize(, 2) = Cells(lChuHo, "D").Resize(, 2).Value
Cells(lChuHo, "D").Resize(, 2).Value = ""
lChuHo = lChuHo + 2
End If
Loop
End Sub