Sub ExportCSV()
Dim t, chemin$, NomFichier$
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
With Sheets("CSV").ListObjects(1).DataBodyRange
Workbooks.Add 'nouveau document
[A1].Resize(.Rows.Count, .Columns.Count) = .Value 'copie les valeurs
End With
With ActiveWorkbook
.SaveAs Filename:=chemin & NomFichier, FileFormat:=xlCSV, local:=True
.Close savechanges:=False
End With
MsgBox Timer - t
End Sub
Sub export()
Dim Tbl As Variant, TblTemp As Variant
Dim FileNumber&, i&, j&
Dim chemin$
Dim T!
T = Timer
FileNumber = FreeFile
chemin = CreateObject("WScript.Shell").specialFolders("Desktop") & "\"
'chemin = "P:\AP\5 B\5 CSV IMPORT\"
chemin = chemin & "Export_" & Sheets("EN TETE").Cells(2, 37) & Format(Date, "_YYYY_MM_DD") & ".csv"
Tbl = ListObjects("CSV").DataBodyRange
Open chemin For Output As #FileNumber
For i = LBound(Tbl, 1) To UBound(Tbl, 1)
ReDim TblTemp(LBound(Tbl, 2) To UBound(Tbl, 2))
For j = LBound(Tbl, 2) To UBound(Tbl, 2)
TblTemp(j) = Tbl(i, j)
Next j
Print #FileNumber, Join(TblTemp, ";")
Next i
Close #FileNumber
MsgBox Timer - T
End Sub
For i = LBound(Tbl, 1) To UBound(Tbl, 1)
ReDim TblTemp(LBound(Tbl, 2) To UBound(Tbl, 2))'Ici'
ReDim TblTemp(LBound(Tbl, 2) To UBound(Tbl, 2))'Ici'
For i = LBound(Tbl, 1) To UBound(Tbl, 1)
Sub export()
Dim Tbl As Variant, TblTemp As Variant
Dim FileNumber&, i&, j&
Dim chemin$
Dim T!
T = Timer
FileNumber = FreeFile
chemin = CreateObject("WScript.Shell").specialFolders("Desktop") & "\"
'chemin = "P:\AP\5 B\5 CSV IMPORT\"
chemin = chemin & "Export_" & Sheets("EN TETE").Cells(2, 37) & Format(Date, "_YYYY_MM_DD") & ".csv"
Tbl = ListObjects("CSV").DataBodyRange
ReDim TblTemp(LBound(Tbl, 2) To UBound(Tbl, 2))
Open chemin For Output As #FileNumber
For i = LBound(Tbl, 1) To UBound(Tbl, 1)
For j = LBound(Tbl, 2) To UBound(Tbl, 2)
TblTemp(j) = Tbl(i, j)
Next j
Print #FileNumber, Join(TblTemp, ";")
Next i
Close #FileNumber
MsgBox Timer - T
End Sub
Tbl = ListObjects("CSV").DataBodyRange
Tbl = sheets("taratata").ListObjects("CSV").DataBodyRange
Sub export()
Dim Tbl As Variant, TblTemp As Variant, FileNumber&, i&, j&, chemin$, T#
T = Timer
FileNumber = FreeFile
chemin = CreateObject("WScript.Shell").specialFolders("Desktop") & "\"
'chemin = "P:\AP\5 B\5 CSV IMPORT\"
chemin = chemin & "Export_" & Sheets("EN TETE").Cells(2, 37) & Format(Date, "_YYYY_MM_DD") & ".csv"
Tbl = Range("CSV").Value
ReDim TblTemp(LBound(Tbl, 2) To UBound(Tbl, 2))
Open chemin For Output As #FileNumber
For i = LBound(Tbl, 1) To UBound(Tbl, 1)
For j = LBound(Tbl, 2) To UBound(Tbl, 2)
TblTemp(j) = Tbl(i, j)
Next j
Print #FileNumber, Join(TblTemp, ";")
Next i
Close #FileNumber
MsgBox Timer - T & vbCrLf & "sur " & i & " lignes et " & j & " colonnes"
End Sub
Exact. J'ai testé le code dans le module de la feuille, donc je n'ai pas rencontré de souci.chez moi par exemple excel 2013
dans un module standard :cette ligne plante
VB:Tbl = ListObjects("CSV").DataBodyRange
set monlistobject=range("CSV").listobject'passe partout