Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: Export records with commas as .txt

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Posts
    107
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am attempting to export records with commas to a .txt file. Examples of my records are:

    121,203
    121,204
    121,205
    etc

    The only problem is that when I export these records to the .txt file, double quotes appear surrounding each record. I need the .txt file records without these double quotes.

    Any ideas? Thanks.

  2. #2
    Board Regular
    Join Date
    Apr 2002
    Location
    Greenwood, SC
    Posts
    677
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    How are you exporting? I do know that the Print# and Write# statements do two different things. Every time I do something like this I have to figure out which one to use.

    A code snippet would be helpful...

    K

  3. #3
    Board Regular
    Join Date
    Apr 2002
    Posts
    107
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sorry I did not clarify. Right now I am not using VBA at all. I am simply going to "Save As" and saving it as a tab deliminated text file.

    I am of course open to a VBA solution.

    Thanks.

  4. #4
    Board Regular
    Join Date
    Apr 2002
    Location
    Greenwood, SC
    Posts
    677
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    It took me a moment to figure out what you were talking about, so let's see if I got it right.

    You have data in an individual cell with commas in it (i.e. A1 might have 121,233) rather than having the data in two separate columns. If this not the case, disregard the rest of this post.

    I tried every save as option there was and could not get rid of the quotes. It's because excel is so darn smart, it thinks you are saving a string (so it must have quotes around it).

    The only way I could get it to work is by using VBA. Assuming your data is just in one column, this will work.

    Sub Do_Output()

    Sheets("Sheet1").select

    Open "C:Output.txt" for Output as #1

    For i = 1 to 10000
    If Cells(i,1).value = "" then exit for
    Print #1, Cells(i,1).value
    Next

    Close

    End Sub

    Hope this helps.

    K

  5. #5
    Board Regular
    Join Date
    Apr 2002
    Posts
    107
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    K:

    You are absolutely correct in what I was asking for. Your VBA solution is EXACTLY what I needed. I did make one minor change:

    Open "C:\Output.txt" for Output as #1
    This line only works as:
    Open "C:Output.txt" for Output as #1

    You are a lifesaver. Thanks!




  6. #6
    Board Regular
    Join Date
    Apr 2002
    Posts
    107
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    K:

    I stand corrected. You provided me the correct code the first time. The board seems to duplicate the "" symbol!

    When you posted
    Open "C:Output.txt" for Output as #1
    it became visible as
    Open "C:\Output.txt" for Output as #1

    Why does the board do this?

    Thanks again for your help.



Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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