Bonjour,

J'ai enregistré la macro ci-dessous avec l'enregistreur de macro, cependant j'aimerais bien que le fichier choisi dans ce cas E:\Communication\Client porteur carte.txt" soit choisi par l'utilisateur, par l'ouverture d'une fenêtre. De plus j'aimerais qu'il demande à l'utilisateur de choisir la longueur du fichier dans ce cas elle est de 25892, pour qu'elle soit changer dans les lignes:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
Selection.AutoFill Destination:=Range("AP3:AP25892"), Type:=xlFillDefault
    Range("AP3:AP25892").Select
 
Selection.AutoFill Destination:=Range("AQ3:AQ25892"), Type:=xlFillDefault
    Range("AP3:AQ25892").Select
 
Selection.AutoFill Destination:=Range("AR3:AR25892"), Type:=xlFillDefault
    Range("AR3:AR25892").Select
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
Sub Import()
'
' Import Macro
' Macro enregistrée le 15/03/2011 par directeur
'
 
'
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;E:\Communication\Client porteur carte.txt", Destination _
        :=Range("A1"))
        .Name = "Client porteur carte_2"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 1252
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = True
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 5, 1, 1, 1, _
        1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
        .TextFileDecimalSeparator = "."
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
 
    Range("AP3").Select
    ActiveCell.FormulaR1C1 = "=IF(C[-27]="""","""",YEAR(TODAY())-YEAR(C[-27]))"
    Range("AP3").Select
    Selection.AutoFill Destination:=Range("AP3:AP25892"), Type:=xlFillDefault
    Range("AP3:AP25892").Select
 
    Range("AQ3").Select
    ActiveCell.FormulaR1C1 = "=IF(C[-25]="""","""",YEAR(C[-25]))"
    Range("AQ3").Select
    Selection.AutoFill Destination:=Range("AQ3:AQ25892"), Type:=xlFillDefault
    Range("AP3:AQ25892").Select
 
    Range("AR3").Select
    ActiveCell.FormulaR1C1 = "=TRIM(RC[-35])"
    Range("AR3").Select
    Selection.AutoFill Destination:=Range("AR3:AR25892"), Type:=xlFillDefault
    Range("AR3:AR25892").Select
    End Sub
Merci de votre aide