Bonjour Xero, le forum,
Je te propose ce code VBA (pas besoin de supprimer des lignes) :
Option Explicit
Sub ReadCSV()
Dim chn$, lng As Byte, nb As Byte, lg&: On Error GoTo ErrFile
Do
chn = InputBox("Nom du fichier (sans l'extension) :", "FileName")
lng = Len(chn): If lng = 0 Then Exit Sub ' sortie si Echap !
Loop Until lng >= 5 ' le nom doit avoir 5 caractères minimum !
Open ActiveWorkbook.Path & "\" & chn & ".csv" For Input As #1
Application.ScreenUpdating = 0
Do While Not EOF(1)
Line Input #1, chn
If nb = 0 Then ' on prend en compte la ligne du fichier
lg = lg + 1: Cells(lg, 1) = chn
End If
nb = nb + 1: If nb = 20 Then nb = 0 ' nombre 20 à adapter
Loop
Close #1: Exit Sub
ErrFile:
MsgBox "Le fichier " & chn & ".csv n'existe pas.", 48, "Nom de fichier erroné"
End Sub
Si besoin, tu peux demander une adaptation.
Merci de me donner ton avis.
C'est seulement si tu as besoin d'une solution VBA, car sinon, la solution d'eriiic sans macro est très bien aussi !
tu as juste à suivre ce lien : https://forum.excel-pratique.com/viewtopic.php?p=651981#p651981
dhany