1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Sub LireFichierTexte()
Dim Plage As Range
Dim Cel As Range
Dim Texte As String
Dim Ligne As String
Dim Index As Integer
Dim Chemin As String
Dim Truc As String
With ActiveSheet
Set Plage = .Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
End With
Truc = "ce que je cherche" 'ici la cellule ou variable contenant la valeur cherchée
Set Cel = Plage.Find(Truc, , xlValues, xlWhole)
If Not Cel Is Nothing Then
Chemin = Cel.Value & ".txt"
Index = FreeFile
Open Chemin For Input As #Index
Do While Not EOF(Index)
Line Input #Index, Ligne
If Texte = "" Then
Texte = Ligne
Else
Texte = Texte & vbCrLf & Ligne
End If
Loop
Close #Index
[Bi] = Texte
End If
End Sub |
Partager