Sub testeexportTXT()
Dim Nblignes As Integer, Nbcol As Integer, i As Integer, j As Integer, S As String
Nblignes = 0
Nbcol = 0
S = ""
i = 1
While Not IsEmpty(Cells(i, 1).Value) 'Compteur nombre de lignes
Nblignes = Nblignes + 1
i = i + 1
Wend
i = 1
While Not IsEmpty(Cells(1, i).Value) 'Compteur nombre de colonnes
Nbcol = Nbcol + 1
i = i + 1
Wend
Open "D:\test.txt" For Output As #1 ' fichier placé dans d:\
For i = 1 To Nblignes
For j = 1 To Nbcol
If j = 3 Then 'Ne pas avoir de ";" entre la colonne 2 et la colonne 3
S = S & Cells(i, j)
Else
S = S & ";" & Cells(i, j)
End If
Next j
Print #1, Right(S, Len(S) - 1) ' Suppression de le première virgule et écriture dans le fichier texte
S = ""
Next i
Close #1
End Sub