Sub Copier()
Dim chemin$, fso As Object, f As Object, pos%, nf$, i As Variant, n%
chemin = ThisWorkbook.Path & "\"
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
'---supprime les fichiers indexés---
For Each f In fso.GetFolder(chemin).Files
If f.Name Like "*#.*" Then
Workbooks(f.Name).Close False 'si le fichier est ouvert on le ferme
Kill chemin & f.Name
End If
Next f
'---copie les fichiers restants---
For Each f In fso.GetFolder(chemin).Files
If f.Name <> ThisWorkbook.Name Then
pos = InStrRev(f.Name, ".")
nf = Left(f.Name, pos - 1)
i = Application.VLookup(nf, Columns("A:B"), 2, 0) 'RECHERCHEV
If IsNumeric(i) Then
For n = 1 To i
fso.CopyFile chemin & f.Name, chemin & nf & n & Mid(f.Name, pos)
Next n
End If
End If
Next f
End Sub