Export records with commas as .txt

Pinball

Board Regular
Joined
Apr 18, 2002
Messages
107
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.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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!
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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