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
| Sub CSV()
Dim i As Long
Dim j As Integer
Dim Col As Integer
Dim sh As Worksheet
Dim strligne As String
'Feuille contenant les données a exporter
Set sh = Sheets("feuil1")
'Chemin et nom du fichier CSV
Open "c:\export.csv" For Output As #1
Col = sh.Rows(1).End(xlToRight).Column
'Boucle sur les données pour création des lignes de données
For i = 1 To sh.Range("A" & Rows.Count).End(xlUp).Row
For j = 1 To Col
If strligne <> "" Then strligne = strligne & ";"
strligne = strligne & sh.Cells(i, Col).Value
Next j
Print #1, strligne
strligne = ""
Next i
'Fermeture du fichier
Close #1
End Sub |
Partager