Salut le forum

Je souhaite reproduire un même traitement sur les autres fichiers texte qui se trouvent dans mon dossier.
Je suis passé par l'enregistreur pour réaliser le code ci-dessous pour un fichier texte de mon dossier.
Le code à me proposer devra importer les autres fichiers et faire le traitement demandé et coller le résultat sur une feuille.
Si possible je souhaite que le nom de la feuille soit tiré du nom du fichier texte (les 5 derniers chiffres du fichier) sachant que le nom du fichier suit cette logique c'est à dire que les 5 derniers chiffres se terminent par des chiffres (5).
Ci-dessous le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Sub traitement()
'
' traitement Macro
'
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\Users\vf002\Desktop\BILAN31052015\ebilncgag01001.rep", Destination _
        :=Range("$A$1"))
        .Name = "ebilncgag01001"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 850
        .TextFileStartRow = 1
        .TextFileParseType = xlFixedWidth
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1)
        .TextFileFixedColumnWidths = Array(6, 8, 6, 16, 20, 20, 20, 8, 9, 9)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
    Range("A:B,E:F").Select
    Range("E1").Activate
    ActiveWindow.SmallScroll ToRight:=2
    Range("A:B,E:F,I:K").Select
    Range("I1").Activate
    Selection.Delete Shift:=xlToLeft
    Range("A16").Select
    ActiveWindow.SmallScroll Down:=-9
    Rows("1:3").Select
    Selection.ClearContents
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Rows("1:3").Select
    Selection.Delete Shift:=xlUp
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "CODE"
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "RC"
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "INTITULE"
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "MONTANT"
    Range("E1").Select
    ActiveCell.FormulaR1C1 = "NOMBRE"
    Range("A2").Select
    ActiveWindow.SmallScroll Down:=-9
 
End Sub