Microsoft 365 Problème format de cellule

netparty

XLDnaute Occasionnel
Bonjour à tous

Je rencontre un soucis dans mon fichier excel et je ne trouve pas la solution.

Voila j'utilise ce fichier pour importer un ficher texte, quand je l'importe les valeurs numériques qui contienne un tiret sont remplacée par des dates pourtant le format de ma cellule est en texte.

Merci pour votre aide

Bonne journée
 

Pièces jointes

  • Données a importer.txt
    7.9 KB · Affichages: 16
  • Gabarit extraction.xlsm
    368 KB · Affichages: 12

Dudu2

XLDnaute Barbatruc
Bonjour,
La macro enregistrée d'importation.
Voir l'instruction .TextFileColumnDataTypes qui met en format Texte la 7ème colonne (G).
VB:
Sub Macro1()
'
' Macro1 Macro
'

'
    Application.CutCopyMode = False
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;H:\Téléchargements\Données a importer.txt", Destination:=Range("$A$2"))
        '.CommandType = 0
        .Name = "Données a importer_1"
        .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 = xlDelimited
        .TextFileTextQualifier = xlTextQualifierSingleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = True
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
        1, 1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With

End Sub
 

Discussions similaires

Statistiques des forums

Discussions
314 019
Messages
2 104 649
Membres
109 092
dernier inscrit
ahm74