Option Explicit
Dim r As Long, Cpt As Long
Function Lire(ByVal NomFichier As String)
Dim Chaine As String
Dim Ar() As String
Dim i As Long
Dim iCol As Long
Dim NumFichier As Integer
Dim Separateur As String * 1
Separateur = ","
Close
NumFichier = FreeFile
Open NomFichier For Input As #NumFichier
Cpt = Cpt + 1
Do While Not EOF(NumFichier)
iCol = 1
Line Input #NumFichier, Chaine
Ar = Split(Chaine, Separateur)
For i = LBound(Ar) To UBound(Ar)
ShFichiers.Cells(r, iCol) = Ar(i)
iCol = iCol + 1
Next
r = r + 1
Loop
Application.StatusBar = " Fichiers : " & Cpt
Close #NumFichier
End Function
Sub OuvertureFichiersMultiples()
Dim fichier As Variant, i As Integer
ChDir ThisWorkbook.Path
fichier = Application.GetOpenFilename("Fichiers Texte,*.txt", 1, "Sélectionner un ou plusieurs fichiers Texte", , True)
If TypeName(fichier) = "Boolean" Then Exit Sub
r = 2: Cpt = 0
ShFichiers.Cells.Clear
Application.ScreenUpdating = False
For i = 1 To UBound(fichier)
Lire fichier(i)
Next i
ShFichiers.Range("D1" ).Select
Application.ScreenUpdating = True
End Sub
|