Bonjour
Je fais une macro excel en prenant des données externes à partir d'un fichier texte/CSV.
J'ai la macro suivante.
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
ActiveWorkbook.Queries.Add Name:="snpp (3)", Formula:= _
        "let" & Chr(13) & "" & Chr(10) & "    Source = Csv.Document(File.Contents(""\\NXPFile001.commun01.svc\VDI_CA-GIP$\Homedir_VDI_CAGIP\U54KR63\My Documents\Thierry\Production\LCL\Suivi acces passerelles SGF\2021\Fichiers Juin 2021\snpp.fcs106m""),[Delimiter="";"", Columns=12, Encoding=1252, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & "    #""Type modifié"" = Table.TransformColumnTypes(Source,{{""Column1"", type" & _
        " text}, {""Column2"", type text}, {""Column3"", type date}, {""Column4"", type text}, {""Column5"", Int64.Type}, {""Column6"", Int64.Type}, {""Column7"", Int64.Type}, {""Column8"", Int64.Type}, {""Column9"", Int64.Type}, {""Column10"", Int64.Type}, {""Column11"", Int64.Type}, {""Column12"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & "    #""Type modifié"""
    ActiveWorkbook.Worksheets.Add
    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
        "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""snpp (3)"";Extended Properties=""""" _
        , Destination:=Range("$A$1")).QueryTable
        .CommandType = xlCmdSql
        .CommandText = Array("SELECT * FROM [snpp (3)]")
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .ListObject.DisplayName = "snpp__3"
        .Refresh BackgroundQuery:=False
    End With
Chaque mois je dois executer cette macro, donc je veux la modifier pour la pérenniser, sauf que je ne sais pas comment avec :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
ActiveWorkbook.Queries.Add Name:="snpp (3)",
Location=""snpp (3)""
 .ListObject.DisplayName = "snpp__3"
A chaque fois que j'execute cette macro, le chiffre s'incrémente et ma macro se plante.
comment faire pour soit incrémenter aussi ce chiffrre, ou le stabiliser à 1 ?
Ou comment supprimer ma requete snpp_3 juste avant ?
Merci.