Te anexo la macro para poner los encabezados
Sub InvoiceNumber()
'Por.Dante Amor
Set h1 = Sheets("datos")
Set h2 = Sheets("ej1")
Set h3 = Sheets("plantilla")
h2.Cells.Clear
'
j = 1
i = 2
'
ant = h1.Cells(2, "F")
encabezado h1, h2, h3, i, j
For i = 2 To h1.Range("F" & Rows.Count).End(xlUp).Row
If ant <> h1.Cells(i, "f") Then
'j = j + 1
encabezado h1, h2, h3, i, j
End If
ant = h1.Cells(i, "F")
productos h1, h2, h3, i, j
Next
h3.Select
MsgBox "Proceso terminado", vbInformation, "PLANTILLA"
End Sub
Sub encabezado(h1, h2, h3, i, j)
'Por.Dante Amor
h3.Rows(1 & ":" & 3).Copy h2.Rows(j)
'
h2.Cells(j, "B") = h1.Cells(i, "F") 'invoice num
h2.Cells(j, "C") = h1.Cells(i, "J") 'invoice date
h2.Cells(j, "D") = h1.Cells(i, "G") 'CURRENCY
h2.Cells(j, "E") = h1.Cells(i, "AB") 'PO
h2.Cells(j, "F") = h1.Cells(i, "O") 'PAYMENT_TERM
j = j + 1
h2.Cells(j, "B") = h1.Cells(i, "A") 'BILL_TO_CUSTOMER_NAME
h2.Cells(j, "C") = h1.Cells(i, "Y") 'VAT NUMNER PURCHASING COMPANY
j = j + 1
h2.Cells(j, "B") = h1.Cells(i, "Z") 'SELLER
h2.Cells(j, "C") = h1.Cells(i, "AA") 'SELLER VAT
j = j + 1
End Sub
Sub productos(h1, h2, h3, i, j)
'Por.Dante Amor
h3.Rows(4 & ":" & 6).Copy h2.Rows(j)
'
h2.Cells(j, "C") = h1.Cells(i, "P") 'DESCRIPTION
j = j + 1
h2.Cells(j, "C") = h1.Cells(i, "K") 'QUANTITY_INVOICED
h2.Cells(j, "D") = h1.Cells(i, "M") 'EXTENDED_AMOUNT
h2.Cells(j, "K") = h1.Cells(i, "V") 'TAX_TOTAL
j = j + 2
End Sub
Saludos.Dante Amor