Option Explicit
Sub genCompta()
Dim lcJournal As Range
Dim rJournal As Range
Dim rCompta As Range
Dim rowsjournal As Range
With fJournal
Set lcJournal = .UsedRange.SpecialCells(xlCellTypeLastCell)
Set rowsjournal = .Range(.[A2], lcJournal).Rows
fCompta.Cells.Clear
End With
Set rCompta = fCompta.[A1:F1]
rCompta.Cells(1, "A") = "date"
rCompta.Cells(1, "B") = "compte"
rCompta.Cells(1, "C") = "libellé"
rCompta.Cells(1, "D") = "montant débit"
rCompta.Cells(1, "E") = "montant crédit"
rCompta.Cells(1, "F") = "Pièce"
Set rCompta = rCompta.Offset(1, 0)
For Each rJournal In rowsjournal
rCompta.Cells(1, "A") = rJournal.Cells(1, "B")
rCompta.Cells(1, "B") = fJournal.[D1]
rCompta.Cells(1, "C") = rJournal.Cells(1, "C")
rCompta.Cells(1, "D") = rJournal.Cells(1, "D")
rCompta.Cells(1, "E") = ""
rCompta.Cells(1, "F") = rJournal.Cells(1, "A")
Set rCompta = rCompta.Offset(1, 0)
rCompta.Cells(1, "A") = rJournal.Cells(1, "B")
rCompta.Cells(1, "B") = fJournal.[E1]
rCompta.Cells(1, "C") = rJournal.Cells(1, "C")
rCompta.Cells(1, "D") = ""
rCompta.Cells(1, "E") = rJournal.Cells(1, "E")
rCompta.Cells(1, "F") = rJournal.Cells(1, "A")
Set rCompta = rCompta.Offset(1, 0)
rCompta.Cells(1, "A") = rJournal.Cells(1, "B")
rCompta.Cells(1, "B") = fJournal.[F1]
rCompta.Cells(1, "C") = rJournal.Cells(1, "C")
rCompta.Cells(1, "D") = ""
rCompta.Cells(1, "E") = rJournal.Cells(1, "F")
rCompta.Cells(1, "F") = rJournal.Cells(1, "A")
Set rCompta = rCompta.Offset(1, 0)
rCompta.Cells(1, "A") = rJournal.Cells(1, "B")
rCompta.Cells(1, "B") = fJournal.[G1]
rCompta.Cells(1, "C") = rJournal.Cells(1, "C")
rCompta.Cells(1, "D") = ""
rCompta.Cells(1, "E") = rJournal.Cells(1, "G")
rCompta.Cells(1, "F") = rJournal.Cells(1, "A")
Set rCompta = rCompta.Offset(1, 0)
Next rJournal
End Sub