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
| Sub Macro1()
Dim Fich As String, Ligne As Long, Form As String
Dim Chemin As String
Dim index As Integer
index = 0
Chemin = "Chemin de mon Rep\"
nom_fich = Chemin & "resuForm.xls"
Fich = Dir(Chemin & "\*.xls")
Form = Chemin & Fich
Set NewBook = Workbooks.Add
NewBook.SaveAs Filename:=nom_fich
Ligne = 1
Do While Fich <> ""
Workbooks.Open Filename:=Form
Worksheets("Onglet1").Activate
Range("A4:A5").Copy
Application.CutCopyMode = False
Workbooks(nom_fich).Worksheets("Feuil1").Activate ' --> Problème d'execution
ActiveSheet.Cells(Ligne, 1).PasteSpecial _
xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=True
ActiveSheet.SaveAs Filename:=nom_fich, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Workbooks(Fich).Close False
Fich = Dir
index = index + 1
Loop
Workbooks(nom_fich).Close False
MsgBox "Nombre de fichiers traités : " & index
End Sub |
Partager