Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSV File format (2003)

    We have to save a file as a CSV file. Is there any way to retain the field formats? It seems to change text fields to numbers if there are numbers like zip codes etc. The fields are formated as text in the original creating program but once saved to csv format - they change. Is there any way to retain the original formatting? Any help would be greatly appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: CSV File format (2003)

    Why do you have to save this as a CSV file?

    CSV stands for comma separated variables. It is a simple text file that has one row for each row in your spreadsheet with commas in between cell values. There is no possibility of storing formatting information in there. Depending on your needs your best bet is probably to keep the original excel file to edit and create a read-only CSV file that is intended for some other purpose.

    StuartR

  3. #3
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CSV File format (2003)

    I believe it is possible using a macro to create the csv file - i.e. "001234" would be saved as it is and not as '1234' - but you would have to run the macro rather than use File > Save As... > (File type: .csv) to create it.

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: CSV File format (2003)

    Is the problem in the creation of the CSV, or reading the CSV? Is Excel creating it or reading it or both?

    Steve

  5. #5
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: CSV File format (2003)

    Assuming the problematic fields are in Columns C; D; and E the following code should work. You will need to add a similar command for each contiguous range of columns you wish converted to text.

    H.T.H.

    <div style="width: 100%; background-color: #FFFFFF;"><code><font color=black><font color=blue>Sub</font color=blue> Format2Text()
    <font color=448800>'</font color=448800>
    Columns("C:E").NumberFormat = "@"
    <font color=blue>End</font color=blue> <font color=blue>Sub</font color=blue>
    </font color=black></code></div hiblock>
    Regards
    Don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •