add comma

  • Thread starter Thread starter Pat
  • Start date Start date
P

Pat

Hi,

I have a spreadsheet with just one column and the column
has 8 digit numbers. About 200 rows. I would like to see
this data exported to a text file with comma between each
number. How can I do that ? Thanks
 
one way:

Public Sub MakeCSV()
Const csDELIM As String = ","
Dim rRecord As Range
Dim sOut As String

Open "Test.txt" For Output As #1
For Each rRecord In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
sOut = sOut & csDELIM & rRecord.Text
Next rRecord
Print #1, Mid(sOut, 2)
Close #1
End Sub
 
Ok, here's a solution for you,

Select the entire data and hit Copy
Now open a new sheet
Put the cursor in the topleft column
In the menu bar, select Edit then Paste Special
A dialog will come up, and there's a checkbox for "Transpose". Check that box.
Now, when you hit OK, it will paste your data horizontally instead of veritcally.
Now, if you export it to CSV (Under Save As, in the file type, find CSV), it will print it as one long continuous string with commas between each number.

These instructions work for OfficeXP, but there should be similar steps in your version of Excel.

Hope that helps!

Dante Gagne
SDE/T
Developer Division
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top