Change to
Sub test()
Dim myAreas As Areas, i As Long, cols As Long
Application.ScreenUpdating = False
With Sheets("data")
With .Range("a2", .Range("d" & Rows.Count).End(xlUp)(0))
cols = .CurrentRegion.Columns.Count
.Value = Application.Trim(.Value)
Set myAreas = .Columns(1).SpecialCells(4).Areas
End With
.Rows(2).Resize(, cols).Copy .Cells(2, cols + 2)
For i = 1 To myAreas.Count
myAreas(i)(0).Resize(, cols).Copy .Cells(i + 2, cols + 2)
With myAreas(i).Offset(, 3).SpecialCells(2)
.Areas(.Areas.Count).Resize(, 8).Copy .Parent.Cells(i + 2, cols + 5)
End With
Next
Range("d" & Rows.Count).End(xlUp).EntireRow.Resize(, cols).Copy
With .Cells(i + 2, cols + 2)
.PasteSpecial
.PasteSpecial xlValues
End With
End With
Application.ScreenUpdating = True
End Sub
Bookmarks