How can I make Excel save a .csv using commas and quotes?












3















I am trying to save file as a .csv, however, Excel is not using the standard comma separator and quotes. Here is an example of what I want:



"0","70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"


This is what Excel is actually giving me:



0   70  0   4/29/2012 12:00 13311250
1 70 0 4/30/2012 12:00 13311250
2 70 0 5/1/2012 12:00 13311250


So what is going on, why am I not even getting any quotation marks? The process I followed was to import the file from .csv (shown in snippet 1) using data from text file option, I modified it, then saved it again as a .csv, but I am getting a file that is formatted the second way.










share|improve this question























  • Is the data in the csv surrounded by quotation marks, or do you want to insert quotation marks as part of the delimiter?

    – Raystafarian
    Jan 23 '17 at 21:12
















3















I am trying to save file as a .csv, however, Excel is not using the standard comma separator and quotes. Here is an example of what I want:



"0","70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"


This is what Excel is actually giving me:



0   70  0   4/29/2012 12:00 13311250
1 70 0 4/30/2012 12:00 13311250
2 70 0 5/1/2012 12:00 13311250


So what is going on, why am I not even getting any quotation marks? The process I followed was to import the file from .csv (shown in snippet 1) using data from text file option, I modified it, then saved it again as a .csv, but I am getting a file that is formatted the second way.










share|improve this question























  • Is the data in the csv surrounded by quotation marks, or do you want to insert quotation marks as part of the delimiter?

    – Raystafarian
    Jan 23 '17 at 21:12














3












3








3


1






I am trying to save file as a .csv, however, Excel is not using the standard comma separator and quotes. Here is an example of what I want:



"0","70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"


This is what Excel is actually giving me:



0   70  0   4/29/2012 12:00 13311250
1 70 0 4/30/2012 12:00 13311250
2 70 0 5/1/2012 12:00 13311250


So what is going on, why am I not even getting any quotation marks? The process I followed was to import the file from .csv (shown in snippet 1) using data from text file option, I modified it, then saved it again as a .csv, but I am getting a file that is formatted the second way.










share|improve this question














I am trying to save file as a .csv, however, Excel is not using the standard comma separator and quotes. Here is an example of what I want:



"0","70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"


This is what Excel is actually giving me:



0   70  0   4/29/2012 12:00 13311250
1 70 0 4/30/2012 12:00 13311250
2 70 0 5/1/2012 12:00 13311250


So what is going on, why am I not even getting any quotation marks? The process I followed was to import the file from .csv (shown in snippet 1) using data from text file option, I modified it, then saved it again as a .csv, but I am getting a file that is formatted the second way.







microsoft-excel microsoft-excel-2010 csv






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 11 '15 at 18:06









John AugustJohn August

121112




121112













  • Is the data in the csv surrounded by quotation marks, or do you want to insert quotation marks as part of the delimiter?

    – Raystafarian
    Jan 23 '17 at 21:12



















  • Is the data in the csv surrounded by quotation marks, or do you want to insert quotation marks as part of the delimiter?

    – Raystafarian
    Jan 23 '17 at 21:12

















Is the data in the csv surrounded by quotation marks, or do you want to insert quotation marks as part of the delimiter?

– Raystafarian
Jan 23 '17 at 21:12





Is the data in the csv surrounded by quotation marks, or do you want to insert quotation marks as part of the delimiter?

– Raystafarian
Jan 23 '17 at 21:12










3 Answers
3






active

oldest

votes


















2














The following site shows the VB macro code to perform the export https://support.chartio.com/knowledgebase/exporting-csv-files-with-double-quotes-from-excel




  1. Open your CSV file in Excel > Find and replace all instances of double quotes (").


  2. Follow the instructions provided in this Microsoft KB article. However, instead of using the macro provided in the Microsoft KB article, use the one below in its place.



Sub QuoteCommaExport()
' Dimension all variables.
Dim DestFile As String
Dim FileNum As Integer
Dim ColumnCount As Long
Dim RowCount As Long
Dim MaxRow As Long
Dim MaxCol As Long


' Prompt user for destination file name.
DestFile = InputBox("Enter the destination filename" _
& Chr(10) & "(with complete path):", "Quote-Comma Exporter")

' Obtain next free file handle number.
FileNum = FreeFile()

' Turn error checking off.
On Error Resume Next

' Attempt to open destination file for output.
Open DestFile For Output As #FileNum

' If an error occurs report it and end.
If Err <> 0 Then
MsgBox "Cannot open filename " & DestFile
End
End If

' Turn error checking on.
On Error GoTo 0

MaxRow = ActiveSheet.UsedRange.Rows.Count
MaxCol = Selection.Columns.Count

MsgBox "Processing this many rows: " & MaxRow
MsgBox "Processing this many columns: " & MaxCol

' Loop for each row in selection.
For RowCount = 1 To MaxRow

' Loop for each column in selection.
For ColumnCount = 1 To MaxCol

' Write current cell's text to file with quotation marks.
Print #FileNum, """" & Selection.Cells(RowCount, _
ColumnCount).Text & """";

' Check if cell is in last column.
If ColumnCount = MaxCol Then
' If so, then write a blank line.
Print #FileNum,
Else
' Otherwise, write a comma.
Print #FileNum, ",";
End If
' Start next iteration of ColumnCount loop.
Next ColumnCount
' Start next iteration of RowCount loop.
Next RowCount

' Close destination file.
Close #FileNum
End Sub





share|improve this answer


























  • Welcome to Super User! Please include the relevant code/information from the linked page in your answer. This will make sure your answer remains useful should the linked page ever change or disappear.

    – Excellll
    Oct 20 '16 at 13:50



















0














Use this script.



Source: Export Excel CSVs with Double Quotes




Excel Macros Microsoft provide access to Visual Basic in the form of
Macros from within Excel that allow us to do things Excel can’t manage
by itself. To create a VB Macro open the Visual Basic Editor (Alt+F11)
then from the menu Insert > Module. This should open a new module code
window that you should copy and paste in the following script:




Sub CSVFile()
Dim SrcRg As Range
Dim CurrRow As Range
Dim CurrCell As Range
Dim CurrTextStr As String
Dim ListSep As String
Dim FName As Variant
FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
ListSep = Application.International(xlListSeparator)
If Selection.Cells.Count > 1 Then
Set SrcRg = Selection
Else
Set SrcRg = ActiveSheet.UsedRange
End If
Open FName For Output As #1
For Each CurrRow In SrcRg.Rows
CurrTextStr = ìî
For Each CurrCell In CurrRow.Cells
CurrTextStr = CurrTextStr & """" & CurrCell.Value & """" & ListSep
Next
While Right(CurrTextStr, 1) = ListSep
CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
Wend
Print #1, CurrTextStr
Next
Close #1
End Sub


It fixed the same problem for me. I had exported a CSV from an application into Excel and when editing it, I was saving CSV files. After checking them, they were without quotes around comma limited values, but this script saves CSV files with quotes, so the saved file can be used in other applications.






share|improve this answer

































    0














    I created a text file with your .csv contents. I then:




    1. imported the .txt into Excel and selected Delimited

    2. I checkboxed tab NOT comma

    3. I selected General not text


    Here is my output:



    0,"70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"



    Each program/application has its own interpretation of what comma delimited really is. In my Excel example, I technically did not use comma delimited but used tab delimited. You could also use text delimited, depending on what you are trying to accomplish.



    Looking through RFC4180, embedded double quotes should be doubled, and the field must be delimited with double-quotes.






    share|improve this answer

























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f971738%2fhow-can-i-make-excel-save-a-csv-using-commas-and-quotes%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      The following site shows the VB macro code to perform the export https://support.chartio.com/knowledgebase/exporting-csv-files-with-double-quotes-from-excel




      1. Open your CSV file in Excel > Find and replace all instances of double quotes (").


      2. Follow the instructions provided in this Microsoft KB article. However, instead of using the macro provided in the Microsoft KB article, use the one below in its place.



      Sub QuoteCommaExport()
      ' Dimension all variables.
      Dim DestFile As String
      Dim FileNum As Integer
      Dim ColumnCount As Long
      Dim RowCount As Long
      Dim MaxRow As Long
      Dim MaxCol As Long


      ' Prompt user for destination file name.
      DestFile = InputBox("Enter the destination filename" _
      & Chr(10) & "(with complete path):", "Quote-Comma Exporter")

      ' Obtain next free file handle number.
      FileNum = FreeFile()

      ' Turn error checking off.
      On Error Resume Next

      ' Attempt to open destination file for output.
      Open DestFile For Output As #FileNum

      ' If an error occurs report it and end.
      If Err <> 0 Then
      MsgBox "Cannot open filename " & DestFile
      End
      End If

      ' Turn error checking on.
      On Error GoTo 0

      MaxRow = ActiveSheet.UsedRange.Rows.Count
      MaxCol = Selection.Columns.Count

      MsgBox "Processing this many rows: " & MaxRow
      MsgBox "Processing this many columns: " & MaxCol

      ' Loop for each row in selection.
      For RowCount = 1 To MaxRow

      ' Loop for each column in selection.
      For ColumnCount = 1 To MaxCol

      ' Write current cell's text to file with quotation marks.
      Print #FileNum, """" & Selection.Cells(RowCount, _
      ColumnCount).Text & """";

      ' Check if cell is in last column.
      If ColumnCount = MaxCol Then
      ' If so, then write a blank line.
      Print #FileNum,
      Else
      ' Otherwise, write a comma.
      Print #FileNum, ",";
      End If
      ' Start next iteration of ColumnCount loop.
      Next ColumnCount
      ' Start next iteration of RowCount loop.
      Next RowCount

      ' Close destination file.
      Close #FileNum
      End Sub





      share|improve this answer


























      • Welcome to Super User! Please include the relevant code/information from the linked page in your answer. This will make sure your answer remains useful should the linked page ever change or disappear.

        – Excellll
        Oct 20 '16 at 13:50
















      2














      The following site shows the VB macro code to perform the export https://support.chartio.com/knowledgebase/exporting-csv-files-with-double-quotes-from-excel




      1. Open your CSV file in Excel > Find and replace all instances of double quotes (").


      2. Follow the instructions provided in this Microsoft KB article. However, instead of using the macro provided in the Microsoft KB article, use the one below in its place.



      Sub QuoteCommaExport()
      ' Dimension all variables.
      Dim DestFile As String
      Dim FileNum As Integer
      Dim ColumnCount As Long
      Dim RowCount As Long
      Dim MaxRow As Long
      Dim MaxCol As Long


      ' Prompt user for destination file name.
      DestFile = InputBox("Enter the destination filename" _
      & Chr(10) & "(with complete path):", "Quote-Comma Exporter")

      ' Obtain next free file handle number.
      FileNum = FreeFile()

      ' Turn error checking off.
      On Error Resume Next

      ' Attempt to open destination file for output.
      Open DestFile For Output As #FileNum

      ' If an error occurs report it and end.
      If Err <> 0 Then
      MsgBox "Cannot open filename " & DestFile
      End
      End If

      ' Turn error checking on.
      On Error GoTo 0

      MaxRow = ActiveSheet.UsedRange.Rows.Count
      MaxCol = Selection.Columns.Count

      MsgBox "Processing this many rows: " & MaxRow
      MsgBox "Processing this many columns: " & MaxCol

      ' Loop for each row in selection.
      For RowCount = 1 To MaxRow

      ' Loop for each column in selection.
      For ColumnCount = 1 To MaxCol

      ' Write current cell's text to file with quotation marks.
      Print #FileNum, """" & Selection.Cells(RowCount, _
      ColumnCount).Text & """";

      ' Check if cell is in last column.
      If ColumnCount = MaxCol Then
      ' If so, then write a blank line.
      Print #FileNum,
      Else
      ' Otherwise, write a comma.
      Print #FileNum, ",";
      End If
      ' Start next iteration of ColumnCount loop.
      Next ColumnCount
      ' Start next iteration of RowCount loop.
      Next RowCount

      ' Close destination file.
      Close #FileNum
      End Sub





      share|improve this answer


























      • Welcome to Super User! Please include the relevant code/information from the linked page in your answer. This will make sure your answer remains useful should the linked page ever change or disappear.

        – Excellll
        Oct 20 '16 at 13:50














      2












      2








      2







      The following site shows the VB macro code to perform the export https://support.chartio.com/knowledgebase/exporting-csv-files-with-double-quotes-from-excel




      1. Open your CSV file in Excel > Find and replace all instances of double quotes (").


      2. Follow the instructions provided in this Microsoft KB article. However, instead of using the macro provided in the Microsoft KB article, use the one below in its place.



      Sub QuoteCommaExport()
      ' Dimension all variables.
      Dim DestFile As String
      Dim FileNum As Integer
      Dim ColumnCount As Long
      Dim RowCount As Long
      Dim MaxRow As Long
      Dim MaxCol As Long


      ' Prompt user for destination file name.
      DestFile = InputBox("Enter the destination filename" _
      & Chr(10) & "(with complete path):", "Quote-Comma Exporter")

      ' Obtain next free file handle number.
      FileNum = FreeFile()

      ' Turn error checking off.
      On Error Resume Next

      ' Attempt to open destination file for output.
      Open DestFile For Output As #FileNum

      ' If an error occurs report it and end.
      If Err <> 0 Then
      MsgBox "Cannot open filename " & DestFile
      End
      End If

      ' Turn error checking on.
      On Error GoTo 0

      MaxRow = ActiveSheet.UsedRange.Rows.Count
      MaxCol = Selection.Columns.Count

      MsgBox "Processing this many rows: " & MaxRow
      MsgBox "Processing this many columns: " & MaxCol

      ' Loop for each row in selection.
      For RowCount = 1 To MaxRow

      ' Loop for each column in selection.
      For ColumnCount = 1 To MaxCol

      ' Write current cell's text to file with quotation marks.
      Print #FileNum, """" & Selection.Cells(RowCount, _
      ColumnCount).Text & """";

      ' Check if cell is in last column.
      If ColumnCount = MaxCol Then
      ' If so, then write a blank line.
      Print #FileNum,
      Else
      ' Otherwise, write a comma.
      Print #FileNum, ",";
      End If
      ' Start next iteration of ColumnCount loop.
      Next ColumnCount
      ' Start next iteration of RowCount loop.
      Next RowCount

      ' Close destination file.
      Close #FileNum
      End Sub





      share|improve this answer















      The following site shows the VB macro code to perform the export https://support.chartio.com/knowledgebase/exporting-csv-files-with-double-quotes-from-excel




      1. Open your CSV file in Excel > Find and replace all instances of double quotes (").


      2. Follow the instructions provided in this Microsoft KB article. However, instead of using the macro provided in the Microsoft KB article, use the one below in its place.



      Sub QuoteCommaExport()
      ' Dimension all variables.
      Dim DestFile As String
      Dim FileNum As Integer
      Dim ColumnCount As Long
      Dim RowCount As Long
      Dim MaxRow As Long
      Dim MaxCol As Long


      ' Prompt user for destination file name.
      DestFile = InputBox("Enter the destination filename" _
      & Chr(10) & "(with complete path):", "Quote-Comma Exporter")

      ' Obtain next free file handle number.
      FileNum = FreeFile()

      ' Turn error checking off.
      On Error Resume Next

      ' Attempt to open destination file for output.
      Open DestFile For Output As #FileNum

      ' If an error occurs report it and end.
      If Err <> 0 Then
      MsgBox "Cannot open filename " & DestFile
      End
      End If

      ' Turn error checking on.
      On Error GoTo 0

      MaxRow = ActiveSheet.UsedRange.Rows.Count
      MaxCol = Selection.Columns.Count

      MsgBox "Processing this many rows: " & MaxRow
      MsgBox "Processing this many columns: " & MaxCol

      ' Loop for each row in selection.
      For RowCount = 1 To MaxRow

      ' Loop for each column in selection.
      For ColumnCount = 1 To MaxCol

      ' Write current cell's text to file with quotation marks.
      Print #FileNum, """" & Selection.Cells(RowCount, _
      ColumnCount).Text & """";

      ' Check if cell is in last column.
      If ColumnCount = MaxCol Then
      ' If so, then write a blank line.
      Print #FileNum,
      Else
      ' Otherwise, write a comma.
      Print #FileNum, ",";
      End If
      ' Start next iteration of ColumnCount loop.
      Next ColumnCount
      ' Start next iteration of RowCount loop.
      Next RowCount

      ' Close destination file.
      Close #FileNum
      End Sub






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jun 12 '17 at 3:16









      phuclv

      9,09463890




      9,09463890










      answered Oct 20 '16 at 13:27









      Mark AshworthMark Ashworth

      214




      214













      • Welcome to Super User! Please include the relevant code/information from the linked page in your answer. This will make sure your answer remains useful should the linked page ever change or disappear.

        – Excellll
        Oct 20 '16 at 13:50



















      • Welcome to Super User! Please include the relevant code/information from the linked page in your answer. This will make sure your answer remains useful should the linked page ever change or disappear.

        – Excellll
        Oct 20 '16 at 13:50

















      Welcome to Super User! Please include the relevant code/information from the linked page in your answer. This will make sure your answer remains useful should the linked page ever change or disappear.

      – Excellll
      Oct 20 '16 at 13:50





      Welcome to Super User! Please include the relevant code/information from the linked page in your answer. This will make sure your answer remains useful should the linked page ever change or disappear.

      – Excellll
      Oct 20 '16 at 13:50













      0














      Use this script.



      Source: Export Excel CSVs with Double Quotes




      Excel Macros Microsoft provide access to Visual Basic in the form of
      Macros from within Excel that allow us to do things Excel can’t manage
      by itself. To create a VB Macro open the Visual Basic Editor (Alt+F11)
      then from the menu Insert > Module. This should open a new module code
      window that you should copy and paste in the following script:




      Sub CSVFile()
      Dim SrcRg As Range
      Dim CurrRow As Range
      Dim CurrCell As Range
      Dim CurrTextStr As String
      Dim ListSep As String
      Dim FName As Variant
      FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
      ListSep = Application.International(xlListSeparator)
      If Selection.Cells.Count > 1 Then
      Set SrcRg = Selection
      Else
      Set SrcRg = ActiveSheet.UsedRange
      End If
      Open FName For Output As #1
      For Each CurrRow In SrcRg.Rows
      CurrTextStr = ìî
      For Each CurrCell In CurrRow.Cells
      CurrTextStr = CurrTextStr & """" & CurrCell.Value & """" & ListSep
      Next
      While Right(CurrTextStr, 1) = ListSep
      CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
      Wend
      Print #1, CurrTextStr
      Next
      Close #1
      End Sub


      It fixed the same problem for me. I had exported a CSV from an application into Excel and when editing it, I was saving CSV files. After checking them, they were without quotes around comma limited values, but this script saves CSV files with quotes, so the saved file can be used in other applications.






      share|improve this answer






























        0














        Use this script.



        Source: Export Excel CSVs with Double Quotes




        Excel Macros Microsoft provide access to Visual Basic in the form of
        Macros from within Excel that allow us to do things Excel can’t manage
        by itself. To create a VB Macro open the Visual Basic Editor (Alt+F11)
        then from the menu Insert > Module. This should open a new module code
        window that you should copy and paste in the following script:




        Sub CSVFile()
        Dim SrcRg As Range
        Dim CurrRow As Range
        Dim CurrCell As Range
        Dim CurrTextStr As String
        Dim ListSep As String
        Dim FName As Variant
        FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
        ListSep = Application.International(xlListSeparator)
        If Selection.Cells.Count > 1 Then
        Set SrcRg = Selection
        Else
        Set SrcRg = ActiveSheet.UsedRange
        End If
        Open FName For Output As #1
        For Each CurrRow In SrcRg.Rows
        CurrTextStr = ìî
        For Each CurrCell In CurrRow.Cells
        CurrTextStr = CurrTextStr & """" & CurrCell.Value & """" & ListSep
        Next
        While Right(CurrTextStr, 1) = ListSep
        CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
        Wend
        Print #1, CurrTextStr
        Next
        Close #1
        End Sub


        It fixed the same problem for me. I had exported a CSV from an application into Excel and when editing it, I was saving CSV files. After checking them, they were without quotes around comma limited values, but this script saves CSV files with quotes, so the saved file can be used in other applications.






        share|improve this answer




























          0












          0








          0







          Use this script.



          Source: Export Excel CSVs with Double Quotes




          Excel Macros Microsoft provide access to Visual Basic in the form of
          Macros from within Excel that allow us to do things Excel can’t manage
          by itself. To create a VB Macro open the Visual Basic Editor (Alt+F11)
          then from the menu Insert > Module. This should open a new module code
          window that you should copy and paste in the following script:




          Sub CSVFile()
          Dim SrcRg As Range
          Dim CurrRow As Range
          Dim CurrCell As Range
          Dim CurrTextStr As String
          Dim ListSep As String
          Dim FName As Variant
          FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
          ListSep = Application.International(xlListSeparator)
          If Selection.Cells.Count > 1 Then
          Set SrcRg = Selection
          Else
          Set SrcRg = ActiveSheet.UsedRange
          End If
          Open FName For Output As #1
          For Each CurrRow In SrcRg.Rows
          CurrTextStr = ìî
          For Each CurrCell In CurrRow.Cells
          CurrTextStr = CurrTextStr & """" & CurrCell.Value & """" & ListSep
          Next
          While Right(CurrTextStr, 1) = ListSep
          CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
          Wend
          Print #1, CurrTextStr
          Next
          Close #1
          End Sub


          It fixed the same problem for me. I had exported a CSV from an application into Excel and when editing it, I was saving CSV files. After checking them, they were without quotes around comma limited values, but this script saves CSV files with quotes, so the saved file can be used in other applications.






          share|improve this answer















          Use this script.



          Source: Export Excel CSVs with Double Quotes




          Excel Macros Microsoft provide access to Visual Basic in the form of
          Macros from within Excel that allow us to do things Excel can’t manage
          by itself. To create a VB Macro open the Visual Basic Editor (Alt+F11)
          then from the menu Insert > Module. This should open a new module code
          window that you should copy and paste in the following script:




          Sub CSVFile()
          Dim SrcRg As Range
          Dim CurrRow As Range
          Dim CurrCell As Range
          Dim CurrTextStr As String
          Dim ListSep As String
          Dim FName As Variant
          FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
          ListSep = Application.International(xlListSeparator)
          If Selection.Cells.Count > 1 Then
          Set SrcRg = Selection
          Else
          Set SrcRg = ActiveSheet.UsedRange
          End If
          Open FName For Output As #1
          For Each CurrRow In SrcRg.Rows
          CurrTextStr = ìî
          For Each CurrCell In CurrRow.Cells
          CurrTextStr = CurrTextStr & """" & CurrCell.Value & """" & ListSep
          Next
          While Right(CurrTextStr, 1) = ListSep
          CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
          Wend
          Print #1, CurrTextStr
          Next
          Close #1
          End Sub


          It fixed the same problem for me. I had exported a CSV from an application into Excel and when editing it, I was saving CSV files. After checking them, they were without quotes around comma limited values, but this script saves CSV files with quotes, so the saved file can be used in other applications.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 12 '17 at 1:15









          Greenonline

          1,2763923




          1,2763923










          answered Jun 12 '17 at 0:44









          rudolphrudolph

          64114




          64114























              0














              I created a text file with your .csv contents. I then:




              1. imported the .txt into Excel and selected Delimited

              2. I checkboxed tab NOT comma

              3. I selected General not text


              Here is my output:



              0,"70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"



              Each program/application has its own interpretation of what comma delimited really is. In my Excel example, I technically did not use comma delimited but used tab delimited. You could also use text delimited, depending on what you are trying to accomplish.



              Looking through RFC4180, embedded double quotes should be doubled, and the field must be delimited with double-quotes.






              share|improve this answer






























                0














                I created a text file with your .csv contents. I then:




                1. imported the .txt into Excel and selected Delimited

                2. I checkboxed tab NOT comma

                3. I selected General not text


                Here is my output:



                0,"70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"



                Each program/application has its own interpretation of what comma delimited really is. In my Excel example, I technically did not use comma delimited but used tab delimited. You could also use text delimited, depending on what you are trying to accomplish.



                Looking through RFC4180, embedded double quotes should be doubled, and the field must be delimited with double-quotes.






                share|improve this answer




























                  0












                  0








                  0







                  I created a text file with your .csv contents. I then:




                  1. imported the .txt into Excel and selected Delimited

                  2. I checkboxed tab NOT comma

                  3. I selected General not text


                  Here is my output:



                  0,"70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"



                  Each program/application has its own interpretation of what comma delimited really is. In my Excel example, I technically did not use comma delimited but used tab delimited. You could also use text delimited, depending on what you are trying to accomplish.



                  Looking through RFC4180, embedded double quotes should be doubled, and the field must be delimited with double-quotes.






                  share|improve this answer















                  I created a text file with your .csv contents. I then:




                  1. imported the .txt into Excel and selected Delimited

                  2. I checkboxed tab NOT comma

                  3. I selected General not text


                  Here is my output:



                  0,"70","0","4/29/2012 12:00","13311250""1","70","0","4/30/2012 12:00","13311250""2","70","0","5/1/2012 12:00","13311250"



                  Each program/application has its own interpretation of what comma delimited really is. In my Excel example, I technically did not use comma delimited but used tab delimited. You could also use text delimited, depending on what you are trying to accomplish.



                  Looking through RFC4180, embedded double quotes should be doubled, and the field must be delimited with double-quotes.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 3 at 16:18









                  Community

                  1




                  1










                  answered Sep 11 '15 at 20:26









                  Austin SandersonAustin Sanderson

                  31939




                  31939






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f971738%2fhow-can-i-make-excel-save-a-csv-using-commas-and-quotes%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      RAC Tourist Trophy