Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to Excel - Comma in a string 1

Status
Not open for further replies.

Trob70

Programmer
Sep 25, 2012
89
AU
I need to create a csv file which is delimited with a comma., and is opened by excel

BUT

On in some cases a field also includes a comma.

Output line eg

aaaaa,bbbbbb,111

i need excel to combine bbbbb,1111 ie not to split it when i open the csv file.
I gather there is some way of using double quotes ????

vba.........?????????

r="bbbbbb,111"
r= replace(r,",","","")

Outline="aaaa" & "," & r



?? something like this

Really appreciate some help

Regards Robert


 
I prefer calculated double quote character to counting "'s:
[tt]Dim sDC as String
sDC = chr(34)
r = "bbbbbb,111"
r = sDC & r & sDC
Outline = "aaaa" & "," & r[/tt]

combo
 
CSV file is a "Comma Separated Value" file, which is just a text file.

If you want a field with a comma in it, yes - enclose the value in a double quotes.
So if your SCV file looks like this:
Code:
field1,field2
aaaaa,"bbbbbb,111"
If you open it in Excel, it wil look like this:
Code:
field1    field2
aaaaa    bbbbbb,111


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top