Sub ExportCSV()
Dim t, chemin$, NomFichier$, F As Worksheet, n%, dest As Range
t = Timer
'chemin = "P:\AP\5 B\5 CSV IMPORT\" ' Ne pas oublier "\" à la fin
chemin = ThisWorkbook.Path & "\"
NomFichier = "Export_" & Sheets("EN TETE").[AK2] & Format(Date, "_yyyy_mm_dd")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set F = Sheets("CSV")
For n = 1 To F.ListObjects.Count
With F.ListObjects(n).DataBodyRange
If n = 1 Then
Workbooks.Add 'nouveau document
Set dest = [A1]
Else
Set dest = dest.Offset(, F.ListObjects(n - 1).DataBodyRange.Columns.Count + 1)
End If
dest.Resize(.Rows.Count, .Columns.Count) = .Value 'copie les valeurs
End With
Next n
With ActiveWorkbook
.SaveAs Filename:=chemin & NomFichier, FileFormat:=xlCSV, local:=True
.Close savechanges:=False
End With
MsgBox "Durée " & Format(Timer - t, "0.00 \sec")
End Sub