![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Posts: 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. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
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 |
|
Board Regular
Join Date: Apr 2002
Posts: 107
|
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 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
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 |
|
Board Regular
Join Date: Apr 2002
Posts: 107
|
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 |
|
Board Regular
Join Date: Apr 2002
Posts: 107
|
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. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|