1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| Option Explicit
Sub EcrituresComptables()
Dim shtRecap As Worksheet
Dim shtEcriture As Worksheet
Dim lngrecapFirstRow As Long 'Ligne dans la feuille récap
Dim lngRecapLastrow As Long 'Dernière ligne du tableau de la feuille récap
Dim lngEcritureRow As Long 'Ligne dans la feuille écriture
Dim i As Long 'Itérateur de boucle
Dim j As Integer
Dim lngPieceCounter As Long 'Compteur de pièce
Const strJOURNAL = "CA"
Const strNPIECEPREFIX = "CA"
Const lngBASEPIECENUMBER = 1001
Const intRECAP_DATE_COLUMN = 1
Const intRECAP_CA0_COLUMN = 2
Const intRECAP_CA10_COLUMN = 3
Const intRECAP_CA20_COLUMN = 4
Const intRECAP_VAT10_COLUMN = 5
Const intRECAP_VAT20_COLUMN = 6
Const intCB_COLUMN = 11
Const intESP_COLUMN = 12
Const intCHQ_COLUMN = 13
Const intECRITURE_DATE_COLUMN = 1
Const intECRITURE_JOURNAL_COLUMN = 2
Const intECRITURE_PIECENUMBER_COLUMN = 3
Const intECRITURE_ACCOUNTNUMBER_COLUMN = 4
'Const intECRITURE_COMMENT_COLUMN = 5
'Const intECRITURE_LABEL_ENTRY = 6
Const intECRITURE_CREDITAMOUNT_COLUMN = 7
Const intECRITURE_DEBITAMOUNT_COLUMN = 8
Const strPROVIDER_ACC_CB = "411CB"
Const strPROVIDER_ACC_ESP = "411ESP"
Const strPROVIDER_ACC_CHQ = "411CHQ"
Const strSALES_ACC_VAT10 = "707100"
Const strSALES_ACC_VAT20 = "707200"
Const strSALES_ACC_VAT0 = "707300"
Const strVAT10_ACC = "445710"
Const strVAT20_ACC = "445720"
Set shtRecap = ThisWorkbook.Sheets("Recap")
Set shtEcriture = ThisWorkbook.Sheets("Ecriture")
lngrecapFirstRow = 4
lngRecapLastrow = shtRecap.Range("A100000").End(xlUp).Offset(-1, 0).Row
lngPieceCounter = lngBASEPIECENUMBER
lngEcritureRow = 2
Application.Calculation = xlCalculationManual
For i = lngrecapFirstRow To lngRecapLastrow
For j = 0 To 7
shtEcriture.Cells(lngEcritureRow + j, intECRITURE_DATE_COLUMN) = shtRecap.Cells(i, intRECAP_DATE_COLUMN)
shtEcriture.Cells(lngEcritureRow + j, intECRITURE_JOURNAL_COLUMN) = strJOURNAL
shtEcriture.Cells(lngEcritureRow + j, intECRITURE_PIECENUMBER_COLUMN) = strNPIECEPREFIX & Right("0000" & lngPieceCounter, 5)
Next j
lngPieceCounter = lngPieceCounter + 1
shtEcriture.Cells(lngEcritureRow + 0, intECRITURE_ACCOUNTNUMBER_COLUMN) = strPROVIDER_ACC_CB
shtEcriture.Cells(lngEcritureRow + 0, intECRITURE_DEBITAMOUNT_COLUMN) = shtRecap.Cells(i, intCB_COLUMN)
shtEcriture.Cells(lngEcritureRow + 1, intECRITURE_ACCOUNTNUMBER_COLUMN) = strPROVIDER_ACC_ESP
shtEcriture.Cells(lngEcritureRow + 1, intECRITURE_DEBITAMOUNT_COLUMN) = shtRecap.Cells(i, intESP_COLUMN)
shtEcriture.Cells(lngEcritureRow + 2, intECRITURE_ACCOUNTNUMBER_COLUMN) = strPROVIDER_ACC_CHQ
shtEcriture.Cells(lngEcritureRow + 2, intECRITURE_DEBITAMOUNT_COLUMN) = shtRecap.Cells(i, intCHQ_COLUMN)
shtEcriture.Cells(lngEcritureRow + 3, intECRITURE_ACCOUNTNUMBER_COLUMN) = strSALES_ACC_VAT10
shtEcriture.Cells(lngEcritureRow + 3, intECRITURE_CREDITAMOUNT_COLUMN) = shtRecap.Cells(i, intRECAP_CA10_COLUMN)
shtEcriture.Cells(lngEcritureRow + 4, intECRITURE_ACCOUNTNUMBER_COLUMN) = strSALES_ACC_VAT20
shtEcriture.Cells(lngEcritureRow + 4, intECRITURE_CREDITAMOUNT_COLUMN) = shtRecap.Cells(i, intRECAP_CA20_COLUMN)
shtEcriture.Cells(lngEcritureRow + 5, intECRITURE_ACCOUNTNUMBER_COLUMN) = strSALES_ACC_VAT0
shtEcriture.Cells(lngEcritureRow + 5, intECRITURE_CREDITAMOUNT_COLUMN) = shtRecap.Cells(i, intRECAP_CA0_COLUMN)
shtEcriture.Cells(lngEcritureRow + 6, intECRITURE_ACCOUNTNUMBER_COLUMN) = strVAT10_ACC
shtEcriture.Cells(lngEcritureRow + 6, intECRITURE_CREDITAMOUNT_COLUMN) = shtRecap.Cells(i, intRECAP_VAT10_COLUMN)
shtEcriture.Cells(lngEcritureRow + 7, intECRITURE_ACCOUNTNUMBER_COLUMN) = strVAT20_ACC
shtEcriture.Cells(lngEcritureRow + 7, intECRITURE_CREDITAMOUNT_COLUMN) = shtRecap.Cells(i, intRECAP_VAT20_COLUMN)
lngEcritureRow = lngEcritureRow + 8
Next i
Application.Calculation = xlCalculationAutomatic
End Sub |
Partager