+ Reply to Thread
Results 1 to 2 of 2

Save as .CSV - Speech marks / extra comma issues

  1. #1
    Registered User
    Join Date
    05-26-2015
    Location
    England
    MS-Off Ver
    2013
    Posts
    18

    Question Save as .CSV - Speech marks / extra comma issues

    Hi All,

    Hoping someone might have a quick solution to the following:

    I have a vba script that is saving a worksheet as a .csv file

    Please Login or Register  to view this content.
    This correctly saves the .csv file, but depending on how I structure the data before .csv converting, I come across one of 2 errors in the output format compared to what I want.

    Option 1
    I have the data as a single text string, separated by commas in Column A.
    When re-opening as a .csv in notepad, this shows the correct information, but with speech marks around the string.

    i.e.

    "a,b,c,d" rather than a,b,c,d

    If I use this method, I need a way of removing the speech marks.

    Option 2
    I separate each bit of text into a column, however the final row of my data always has data in one extra column (an asterisk) to signify its the final line.
    This cannot be removed as the .csv file requires this to be processed correctly.

    Because of this, I get an additional, unwanted comma at the end of each row until the final line, highlighted in red below.

    i.e.

    a,b,c,d,
    e,f,g,h,
    i,j,k,l,*

    Any ideas how I can get the desired output:

    i.e.

    a,b,c,d
    e,f,g,h
    i,j,k,l,*

    Thanks

    Rob
    Last edited by wahbob; 06-09-2021 at 06:50 AM.

  2. #2
    Registered User
    Join Date
    05-26-2015
    Location
    England
    MS-Off Ver
    2013
    Posts
    18

    Re: Save as .CSV - Speech marks / extra comma issues

    If anyone stumbles across this, I've managed to find a solution - although not particularly neat.

    I create the .csv using the Option 2 method I described in the original post, but exclude the asterisk from the final line.

    Once the .csv has been saved, I loop through the lines to edit adding the commas where necessary and then amend the final line to add the asterisk. line.

    Please Login or Register  to view this content.
    solution adapted from [URL="https://stackoverflow.com/questions/33120961/how-can-i-edit-a-currently-existing-csv-file-at-specific-rows-in-vba"]

    I have to admit, I'm not entirely sure about Scripting.FileSystemObject as I've never used it before, but it works!

    Thanks to everyone that took a look at this.

    Wahbob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Adding CHAR(10) to add line breaks causes speech marks to be added
    By Fozzy279 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-13-2020, 12:10 PM
  2. Formula to remove speech marks
    By james19 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-07-2014, 11:20 AM
  3. Help require to delete or reduce extra marks
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-15-2014, 06:46 PM
  4. how to remove text contained with speech marks
    By pablowilks in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 03:32 PM
  5. [SOLVED] drag-down of indirect function does not change cell refereence between speech marks
    By nils7 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-07-2012, 04:51 AM
  6. Adding a formula to a cell. Speech marks
    By Typicalalex1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-07-2011, 07:36 AM
  7. [SOLVED] Why does a sumif use double speech marks
    By owl37 in forum Excel General
    Replies: 1
    Last Post: 11-24-2005, 10:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1