LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default export to csv file (comma problem)

Hi
I am using the following code to export data in excel file (muliple columns)
to csv file
sub Export_toCSV()
ThisWorkbook.Sheets(1).Range("actlist").Select ' actlist is a named rage (3
columns)
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
True, Transpose:=False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=path, FileFormat:=xlCSVMSDOS,
CreateBackup:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True
ThisBook.Activate
ThisBook.Worksheets(1).Range("A1").Activate
End sub()

Here is what I am getting.
22900002,46002759,
22900003,46002776,22525548
22900040,46002806,
22995012,46002873,25658415
22995014,46002877,
22995103,46002982,
22995111,,
22995117,,
22995127
22995128
22995153

What I DON'T understand is why there are two commas put in for 22995111 &
22995127. (if the 3rd column does not have data, 1 comma put in for the same
numbers)
Also, why the comma is at the end for some rows but not for others. I need
consistency. if the comma is put always, I need the comma even for the last
column.
OR the comma should not be there if there are no data on the next column.

22995012,46002873,25658415
22995014,46002877,

Note: when I write to the file line by line with print statement its OK but
the performance is very slow.

Any help appreciated.

Thanks in advance

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
export re-order input fields to export file [csv] madisonpete Excel Worksheet Functions 0 November 30th 07 03:51 PM
Export txt file problem Oscar Excel Programming 3 July 21st 06 02:25 PM
How do I export data from Excel as a series of comma-separated val gbergren New Users to Excel 2 January 20th 06 08:17 PM
Export file problem for TXT file. shital shah Excel Programming 1 January 24th 05 11:14 AM
Excel How do I create a comma delineated xls file to a comma delineated. Mark Excel Discussion (Misc queries) 0 November 26th 04 10:28 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"