Option Explicit
Sub EnregistrementTexte()
Dim Chaine As String
Dim i As Long, j As Long
Dim NumFichier As Integer
Dim LastRow As Long, LastCol As Integer
Dim Separateur As String * 1
Separateur = ";"
NumFichier = FreeFile
LastRow = ShTest.Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Open ThisWorkbook.Path & "\test.txt" For Output As #NumFichier
For i = 1 To LastRow
LastCol = ShTest.Range("IV" & i).End(xlToLeft).Column
Chaine = ""
For j = 1 To LastCol
If j = 1 Then
Chaine = ShTest.Cells(i, j)
Else
Chaine = Chaine & Separateur & ShTest.Cells(i, j)
End If
Next j
Print #NumFichier, Chaine
Next i
Close #NumFichier
End Sub
|