XL 2010 Macro export csv en ;

djam28

XLDnaute Occasionnel
Bonjour à tous,
J'ai une macro qui permet d'exporter ma feuille en csv et je voudrais la modifier de façon à ce que fichier exporté soit directement en ; et non en ,
La voici :

Public Sub SaveAsCSV1()
Dim wb As Workbook, ws As Worksheet
Dim strPath As String, strFilename As String
Set wb = ThisWorkbook
Set ws = wb.Worksheets("Biobank_M0")
strPath = wb.Path & Application.PathSeparator
strFilename = "Biobank_M0.csv"
ws.Copy
With ActiveWorkbook
.SaveAs Filename:=strPath & strFilename, _
FileFormat:=xlCSV, _
local:=True '? adapter
.Close savechanges:=False
End With
End Sub

Merci de votre aide
Bonne journée
DE
 
Solution
Bonsoir,

à tester
VB:
Option Explicit
Public Sub SaveAsCSV1()
    Dim wb As Workbook, ws As Worksheet, plage As Range
    Dim strPath As String, strFilename As String
    Dim f As Integer, L As Integer, chaine As String, c As Integer
    Set wb = ThisWorkbook
    Set ws = wb.Worksheets("Biobank_M0")
    strPath = wb.Path & Application.PathSeparator
    strFilename = strPath & "/" & "Biobank_M0.csv"
    With ws
        Set plage = .UsedRange
        f = FreeFile()
        Open strFilename For Output As #f
        For L = 1 To plage.Rows.Count
            chaine = plage.Cells(L, 1)
            For c = 2 To plage.Columns.Count
                chaine = chaine & ";" & plage.Cells(L, c)
            Next c
            Print #f, chaine...

cp4

XLDnaute Accro
Bonsoir,

à tester
VB:
Option Explicit
Public Sub SaveAsCSV1()
    Dim wb As Workbook, ws As Worksheet, plage As Range
    Dim strPath As String, strFilename As String
    Dim f As Integer, L As Integer, chaine As String, c As Integer
    Set wb = ThisWorkbook
    Set ws = wb.Worksheets("Biobank_M0")
    strPath = wb.Path & Application.PathSeparator
    strFilename = strPath & "/" & "Biobank_M0.csv"
    With ws
        Set plage = .UsedRange
        f = FreeFile()
        Open strFilename For Output As #f
        For L = 1 To plage.Rows.Count
            chaine = plage.Cells(L, 1)
            For c = 2 To plage.Columns.Count
                chaine = chaine & ";" & plage.Cells(L, c)
            Next c
            Print #f, chaine
        Next L
        Close #f
    End With
MsgBox "terminé!"
End Sub

Pour éditer correctement code sur XLD
Balise de code.gif
Bonne soirée.
 

djam28

XLDnaute Occasionnel
Bonsoir,

à tester
VB:
Option Explicit
Public Sub SaveAsCSV1()
    Dim wb As Workbook, ws As Worksheet, plage As Range
    Dim strPath As String, strFilename As String
    Dim f As Integer, L As Integer, chaine As String, c As Integer
    Set wb = ThisWorkbook
    Set ws = wb.Worksheets("Biobank_M0")
    strPath = wb.Path & Application.PathSeparator
    strFilename = strPath & "/" & "Biobank_M0.csv"
    With ws
        Set plage = .UsedRange
        f = FreeFile()
        Open strFilename For Output As #f
        For L = 1 To plage.Rows.Count
            chaine = plage.Cells(L, 1)
            For c = 2 To plage.Columns.Count
                chaine = chaine & ";" & plage.Cells(L, c)
            Next c
            Print #f, chaine
        Next L
        Close #f
    End With
MsgBox "terminé!"
End Sub

Pour éditer correctement code sur XLD
Regarde la pièce jointe 1137405
Bonne soirée.
Bonsoir Cp4,
Mille mercis ++++, ça fonctionne très bien et instantanée
Bonne soirée
 

Discussions similaires

Statistiques des forums

Discussions
298 771
Messages
1 971 605
Membres
203 412
dernier inscrit
elrico22