the best way is to save it in a text file with the csv extension:
Sub ExportToCSV() Dim i, j As Integer Dim Name As String Dim pathfile As String Dim fs As Object Dim stream As Object Set fs = CreateObject("Scripting.FileSystemObject") On Error GoTo fileexists i = 15 Name = Format(Now(), "ddmmyyHHmmss") pathfile = "D:\1\" & Name & ".csv" Set stream = fs.CreateTextFile(pathfile, False, True)
FileExists:
If Err.Number = 58 Then MsgBox "File already Exists" 'Your code here Return End If On Error GoTo 0 j = 1 Do Until IsEmpty(ThisWorkbook.ActiveSheet.Cells(i, 1).Value) stream.WriteLine (ThisWorkbook.Worksheets(1).Cells(i, 1).Value & ";" & Replace(ThisWorkbook.Worksheets(1).Cells(i, 6).Value, ".", ",")) j = j + 1 i = i + 1 Loop stream.Close End Sub
AzizD Jul 31 '17 at 6:28 2017-07-31 06:28
source share