Bonjour,
Voilà ce que ça m'indique quand je clique sur "Débogage "
Mais je n'y connais rien,désolé de ne pouvoir de te donner la ligne précise.
J'ai copié ton fichier dans le même répertoire que mon fichier txt et xlsx et quand je clique sur " vérification",j'ai un message "erreur d’exécution 1004". Est ce que ça marche chez toi ?
Je clique sur "Débogage" et voici ce que ça dit:
Option Explicit
Sub Compare()
Dim Ws As Worksheet
Dim J As Long
Dim Chemin As String, Fichier As String
Dim Wb As Workbook
Dim Cel As Range
Application.ScreenUpdating = False
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Txt").Delete
On Error GoTo 0
Application.DisplayAlerts = True
Chemin = ThisWorkbook.Path & Application.PathSeparator
Fichier = "TRPU TT EM017839.txt"
Workbooks.OpenText Filename:=Chemin & Fichier, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), TrailingMinusNumbers:=True
Set Wb = ActiveWorkbook
Wb.Sheets(1).Move after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ActiveSheet.Name = "Txt"
Columns("E:E").TextToColumns Destination:=Range("J1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:="#", _
FieldInfo:=Array(Array(1, 1), Array(2, xlTextFormat), Array(3, xlTextFormat), Array(4, 1)), _
TrailingMinusNumbers:=True
Range("K2:K" & Range("K" & Rows.Count).End(xlUp).Row).Replace what:="-", replacement:="", lookat:=xlPart
With Sheets(1)
.Range("A2:O" & .Range("A" & Rows.Count).End(xlUp).Row).Interior.ColorIndex = xlNone
For J = 2 To .Range("C" & Rows.Count).End(xlUp).Row
Set Cel = Columns("K").Find(what:=Mid(.Range("C" & J), 4), LookIn:=xlValues, lookat:=xlWhole)
If Not Cel Is Nothing Then
If Cel.Offset(0, -5) = .Range("H" & J) And Cel.Offset(0, 1) = .Range("G" & J) Then
.Range("A" & J & ":O" & J).Interior.ColorIndex = 34
End If
End If
Next J
.Select
End With
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Txt").Delete
On Error GoTo 0
Application.DisplayAlerts = True
End Sub
Cordialement.
Hervé