column list

J

jose vargas

can someone help? i need to export a list to a word-
wrapped with commas text document

My spreadsheet has 500 such numbers:

Column A
4567
45676
23434
442344

desired outpu:
4567,45676,23434,442344

Thanks
 
P

Peter Rooney

Hi, Jose!

Try this - you'll need to select the cells in your worksheet first, and
obviously subsitute an appropriate path and filename in the save as line

Hope this helps

Pete

Sub ListToTest()
Dim ListCounter As Integer
Dim ConCatString As String
ConCatString = ""
For ListCounter = 1 To Selection.Cells.Count
ConCatString = ConCatString & CStr(Selection.Cells(ListCounter)) & ","
Next ListCounter
Workbooks.Add
Range("A1").Formula = ConCatString
ActiveWorkbook.SaveAs Filename:="D:\Pete's Operations\VBA\Example.csv", _
FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
End Sub
 
Top