Option Explicit
Sub TEST2()
Dim ar, br, i&, Rng As Range, iPosRow&
Application.ScreenUpdating = False
With [A1].CurrentRegion
With Intersect(.Offset(), .Offset(1))
ar = .Value
ReDim br(1 To UBound(ar), 2)
For i = 1 To UBound(ar)
br(i, 0) = ar(i, 1)
br(i, 1) = .Cells(i, 2).Resize(, 13).Value
br(i, 2) = .Cells(i, 15).Resize(, 13).Value
Next i
End With
End With
Set Rng = [AD1:AR13]
With Workbooks.Add
For i = 1 To UBound(br)
iPosRow = (i - 1) * 14 + 1
With .Worksheets(1)
rngCopyToSame Rng, .Cells(iPosRow, 1)
With .Cells(iPosRow, 1)
.Cells(2, 1).Value = br(i, 1): .Cells(2, 4).Value = br(i, 0)
.Cells(2, 3).Resize(, 13) = br(i, 1)
.Cells(4, 3).Resize(, 13) = br(i, 2)
End With
End With
Next i
End With
Application.ScreenUpdating = True
Beep
End Sub
Function rngCopyToSame(ByVal rngSel As Range, ByVal rngTarget As Range)
Dim i&
rngSel.Copy
rngTarget.PasteSpecial xlPasteColumnWidths
rngSel.Copy rngTarget
With rngTarget.Resize(rngSel.Rows.Count, rngSel.Columns.Count)
For i = 1 To .Rows.Count
.Rows(i).RowHeight = rngSel.Rows(i).RowHeight
Next i
End With
End Function
|