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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| Sub Export_CSV()
Dim Classeur, Classeur2 As Workbook
Dim NbCl, NbLg, FnCl As Integer
Dim ValCel, Guillemets As String
Set Classeur = ActiveWorkbook
NbLg = 1
FnCl = 3 ' 206
Guillemets = """"
'Selection de la Feuille Tableau
Classeur.Sheets("TABLEAU").Select
'Boucle de test de ligne
Do
'Boucle de accès aux cellules (colonnes)
For NbCl = 1 To FnCl Step 1
ValCel = Cells(NbLg, NbCl)
If ValCel <> "" Then
Cells(NbLg, NbCl) = Guillemets & ValCel & Guillemets
End If
Next NbCl
'Remise à 1 du compteur de colonne
NbCl = 1
'Avance d'un pas compteur de ligne
NbLg = NbLg + 1
If Cells(NbLg, NbCl) = "" Then
MsgBox " Le nombre de vos lignes converties sont :" & NbLg
End If
Loop Until IsEmpty(Cells(NbLg, NbCl))
NbLg = 1
Do
For NbCl = 2 To FnCl Step 1
Cells(NbLg, 1) = Cells(NbLg, 1) & ";" & Cells(NbLg, NbCl)
Next NbCl
NbCl = 1
NbLg = NbLg + 1
Loop Until IsEmpty(Cells(NbLg, NbCl))
NbLg = 1
NbLg = 1
Do
For NbCl = 2 To FnCl Step 1
Cells(NbLg, NbCl) = ""
Next NbCl
NbCl = 1
NbLg = NbLg + 1
Loop Until IsEmpty(Cells(NbLg, NbCl))
Classeur.SaveAs Filename:="C:\Peupl.csv", FileFormat:=xlCSV, CreateBackup:=False, Local:=True
Workbooks("Peupl.csv").Close savechanges:=True
End Sub |
Partager