CSV Quotation Mark Help

Frazz89

New Member
Joined
Mar 28, 2014
Messages
3
Hi,

I need to export a CSV file from my CRM to be imported into SAGE 200. The problem is that I need string fields to have quotation marks around them. I cannot find a way to have the quotation marks show only, for example, on columns A, C and D.

When I try and add them manually instead of showing "Test" it will show ""Test"" (when i open in notepad) or with even more extras. I was sent an example CSV and the excel spreadsheet itself doesn't show them but when opening in notepad it does.

Can anyone help?

Thank you!

Fraser
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Excel won't show them but if you format the column as text it should save the file with quotations.
 
Upvote 0
I tried that initially, as I believed any text field would 'update' to have quotation marks in a CSV format. However when I test this by opening the CSV in notepad, they are not showing.
 
Upvote 0
You could add the quotation marks in excel and then open it in notepad and find and replace """ with ". Too bad excel doesn't seem to have any options for csv file saving.
 
Upvote 0
Looks like it may be the only option, which is going to be a problem with so many reports exported/imported weekly!
 
Upvote 0
You could use this macro I found on another thread. I've modified it so it only puts quotes around cells formatted as text. It looks like if you have a selection it saves only that but if you only select 1 cell it will save the usedrange of the spreadsheet.

Code:
Sub SaveCSVFile()


    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")


    If FName <> False Then
        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
                If CurrCell.NumberFormat = "@" Then
                    CurrTextStr = CurrTextStr & """" & CurrCell.Value & """" & ListSep
                Else
                    CurrTextStr = CurrTextStr & CurrCell.Value & ListSep
                End If
            Next
            While Right(CurrTextStr, 1) = ListSep
                CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
            Wend
            Print #1, CurrTextStr
        Next
        Close #1
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,438
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top