Option Explicit
Sub Tst()
Dim Fichier As Variant
ChDir ThisWorkbook.Path
Fichier = Application.GetOpenFilename("Text Files (*.csv), *.csv" )
If Fichier <> False Then
Lire Fichier
End If
End Sub
Sub Lire(ByVal NomFichier As String)
Dim Chaine As String
Dim Ar() As String
Dim i As Long
Dim iRow As Long, iCol As Long
Dim NumFichier As Integer
Dim Separateur As String * 1
' Séparateur Point Virgule
Separateur = ";"
Cells.Clear
Application.ScreenUpdating = False
NumFichier = FreeFile
iRow = 1
Open NomFichier For Input As #NumFichier
Do While Not EOF(NumFichier)
iCol = 1
Line Input #NumFichier, Chaine
Ar = Split(Chaine, Separateur)
For i = LBound(Ar) To UBound(Ar)
Ar(i) = Replace(Ar(i), "M-", "" )
Cells(iRow, iCol) = Ar(i)
iCol = iCol + 1
Next
Select Case Cells(iRow, 1)
Case Is = Cells(iRow, 2): Cells(iRow, 3) = "Ok"
Case Else: Cells(iRow, 3) = "Bad"
End Select
iRow = iRow + 1
Loop
Close #NumFichier
Application.ScreenUpdating = True
End Sub
|