Sub Macro1()
'COPIE LES VALEURS SELON CRITERE
Dim i&, j&
j = 2
With Feuil2
For i = 2 To .[AB65536].End(xlUp).Row
If .Cells(i, 28) = [E1] Then
Cells(j, 1) = .Cells(i, 17)
Cells(j, 2) = .Cells(i, 27)
j = j + 1
End If
Next
End With
'COPIE DU PDF
Dim Cel As Range, Copie As Boolean ' Dim pour tous les copies
For Each Cel In Range("B" & Rows.Count).End(xlUp)
If Cel.Value <> "" Then
FileCopy ActiveWorkbook.Path & "\Facture\PDF\" & Cells(Cel.Row, 2) & ".pdf", _
Cells(Cel.Row, 3).Value & Cells(Cel.Row, 2) & ".pdf" 'FICHIER=2, CIBLE=3
Copie = True
End If
Next
'COPIE DU XLSX
For Each Cel In Range("B" & Rows.Count).End(xlUp)
If Cel.Value <> "" Then
FileCopy ActiveWorkbook.Path & "\Facture\" & Cells(Cel.Row, 2) & ".xlsx", _
Cells(Cel.Row, 3).Value & Cells(Cel.Row, 2) & ".xlsx" 'FICHIER=2, CIBLE=3
Copie = True
End If
Next
'COPIE DU JPG
For Each Cel In Range("B" & Rows.Count).End(xlUp)
If Cel.Value <> "" Then
FileCopy ActiveWorkbook.Path & "\Contrat\" & Cells(Cel.Row, 2) & ".jpg", _
Cells(Cel.Row, 4).Value & Cells(Cel.Row, 2) & ".jpg" 'FICHIER=2, CIBLE=3
Copie = True
End If
Next
'COPIE DU JPG (2)
On Error Resume Next
For Each Cel In Range("B" & Rows.Count).End(xlUp)
If Cel.Value <> "" Then
FileCopy ActiveWorkbook.Path & "\Contrat\" & Cells(Cel.Row, 2) & " (2).jpg", _
Cells(Cel.Row, 4).Value & Cells(Cel.Row, 2) & " (2).jpg" 'FICHIER=2, CIBLE=3
Copie = True
End If
Next
If Copie = True Then MsgBox "Copie terminé"
End Sub