Sub test()
Sub test()
Dim v As Variant
Dim i As Long, lastRow As Long
Dim WksSuivi As Worksheet, WksAP As Worksheet, WksCP As Worksheet
Set WksSuivi = ThisWorkbook.Sheets("Suivi Transfert")
Set WksAP = ThisWorkbook.Sheets("AP-AE")
Set WksCP = ThisWorkbook.Sheets("CP")
With Application
.ScreenUpdating = False
.Calculation = xlManual
.DisplayAlerts = False
End With
lastRow = WksSuivi.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
'Stocker les valeurs dans une variable tableau (Array)
v = WksSuivi.Range("A1:S" & lastRow).Value
For i = 2 To lastRow
WksAP.Range("A6").Value = v(i, 9) 'Colonne I Programme
WksAP.Range("B6").Value = v(i, 10) 'Colonne J AP
WksAP.Range("G6").Value = v(i, 14) 'Colonne N Montant
WksAP.Range("A22") = v(i, 6) 'Colonne F BDC
WksAP.Range("C22") = v(i, 8) 'Colonne E Objet
WksAP.Range("B23") = v(i, 2) 'Colonne B Direction Origine
WksAP.Range("D23") = v(i, 1) 'Colonne A direction Transfert
WksAP.Range("C24") = v(i, 3) 'Colonne C contact transfert
WksAP.Range("B19") = v(i, 7) 'Colonne C fournisseur
WksAP.Range("H19") = v(i, 5) 'Colonne C evenement
WksAP.Range("N23").Value = Format(Now, "mm/dd/yyyy") 'Colonne C date
WksAP.Range("I20").Value = v(i, 14) 'Colonne N Montant talon
WksCP.Range("A7").Value = v(i, 9) 'Colonne I Programme
WksCP.Range("J7").Value = v(i, 14) 'Colonne N Montant
WksCP.Range("B7").Value = v(i, 12) 'Colonne N LC
WksCP.Range("D7").Value = v(i, 13) 'Colonne N Montant
Sheets(Array("AP-AE", "CP")).Copy
With ActiveWorkbook
.SaveAs ThisWorkbook.Path & "\" & "Fiche TC_AE_CP " & Format(i - 1, "000") & ".xlsx", FileFormat:=xlWorkbookDefault
.Close
End With
With WksAP
.Range("A6, B6, G6, A22, C22, B23, D23, C24, I20, B19, H19, N23, I20").ClearContents
.Cells(22, 3).MergeArea.ClearContents
WksCP
.Range("A7, J7, B7, D7").ClearContents
.Cells(22, 3).MergeArea.ClearContents
End With
Next i
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.DisplayAlerts = True
End With
End Sub