+ Reply to Thread
Results 1 to 8 of 8

Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

  1. #1
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

    I am a little lost in making this work.

    I found a few examples around the web of exporting to CSV with Double Quotes. For example:

    http://www.markinns.com/articles/ful..._double_quotes

    http://windowssecrets.com/forums/sho...-around-values

    But I can't come up with a way to export to CSV with the first column not receiving the double quotes.

    Any thoughts?
    Last edited by justforthis1; 02-14-2012 at 09:16 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

    Provide us some sample data.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Re: Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

    Hopefully these work...

    The xls is an example of the data I would be using.

    The txt is an example of the output I would be looking for.

    Thanks.
    Attached Files Attached Files

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

    I checked the output file. Why is there an extra set of double quotes at the end of each line?

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

    Maybe:
    Please Login or Register  to view this content.
    You can add the additional quotes at the end if you like

  6. #6
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Re: Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

    Quote Originally Posted by arlu1201 View Post
    I checked the output file. Why is there an extra set of double quotes at the end of each line?
    The extra set is because that field is 99.99% of the time empty. I would like to include it if possible. Not sure if it is while also removing the blanks in the top and bottom rows?


    Quote Originally Posted by Kyle123 View Post
    Maybe:
    Please Login or Register  to view this content.
    You can add the additional quotes at the end if you like
    That seems to work. If you don't mind talking me through some of it? I don't have a lot of experience with Arrays. (though I have been reading on them quite a bit since your solution)

    arr is an array composed of all the active data right?
    col1 is a "transposed" version of the first column into a 2nd array? could you explain what the .Index(...) portion is?

    x is really just a counter that caps at the UBound of the arr array?

    stri is where i think i am having the hardest time following. Replace is finding the delimiter in the array and replacing them with """,""" etc? If you could break that whole line down for me that would be awesome...

    then we take the Col1 array which is just the first line then add back in the arr array subtracting out the length of the Col1 array correct?

    If i wanted to keep the extra double quotes at the end - would that end up in the stri line of code?
    If any of the cells are left blank it seems to shift over without leaving blank delimiters - could you explain why that is from a coding perspective? and can it be changed?


    If you don't have time to explain it to me i understand, and thanks VERY much for your help.

    If you do have time to explain then great I like to understand what I am doing and apply it to things i do in the future ... rather than just getting "free coding support" kind of thing... :D

    Thanks again for both of your time.

  7. #7
    Registered User
    Join Date
    09-13-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

    I don't know much coding but if I want to add quotes in fist column and no quotes in second column what changes I need to make in above module. I have tried few things but it doesn't seem to work. I will kee trying but any help you can provide will be appriciated.

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Save to a CSV with Double Quotes EXCEPT the First Column with NO Quotes

    Hello tkuy2k & Welcome to the Forum,

    Administrative Note:
    • Somebody would be happy to help with your query, but first, before we can proceed…
    • Please see Forum Rule #2...Do not post a question in the thread of another member -- start your own thread..
    • If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.
    • Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    HTH
    Regards, Jeff

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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