+ Reply to Thread
Results 1 to 9 of 9

Macro to convert comma delimited csv file to excel file??

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    Macro to convert comma delimited csv file to excel file??

    Hi Friends,

    I have recently been troubled with a problem of converting comma delimited csv files to xlsx format excel files. I dont, know a code to make it automatic, neither a macro, so I open the individual file and do "save as .xlsx", which doesn't seem practical anymore with dozens to convert each day.

    It's a bit confusing as well because when I open the individual CSV file it opens in excel and i save it as xlsx, but when I used some simple macros it didn't work that way, the macro took it as a text (txt) file! Why is that so wonder?

    Could you suggest me how to make this process automatic, using a macro? It could be easier to hardcode the files location or let the macro ask me the folder location to run the process.

    Thanks alot in advance for your generous replies and solutions.
    Sanjeev

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to convert comma delimited csv file to excel file??

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Macro to convert comma delimited csv file to excel file??

    Hi patel45, thanks for your reply.

    I tried but the code you wrote above is not working. I used a function 'getfolder' to locate the files which allows me to multiselect csv files and operates on them one by one. I want it to run through all the csv files in the folder, but that's not what I'm getting afterall.

    It just opens the first csv file and doesn't do anything at all with it, moreover, it opens the csv in excel but doesn't open it the same way as I open it myself, the files individually (in this case the excel shows data in two different columns A and B and that's what I want from the macro as well)..

    do you understand where is the bug in this?

    Thanks!

  4. #4
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Macro to convert comma delimited csv file to excel file??

    Sorry for double post, I don't know how it happened.

  5. #5
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to convert comma delimited csv file to excel file??

    Attach your code and your csv file for testing

  6. #6
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Macro to convert comma delimited csv file to excel file??

    thanks again for your help.

    Attached below is the zip folder containing two CSV files to test and the macro (CSV to XLS.xlsm).
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to convert comma delimited csv file to excel file??

    try this
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Macro to convert comma delimited csv file to excel file??

    Hi, your code worked but it copies the data in the activesheet, which is the excel (xlsm) file itself containing the macro! I want the file to open in the same format and get saved as xlsx format (open the csv file and save the same in the excel format with the same title)

    I get the error: Execution error '1004': Error defined by the application or by the object

    Attached Below is the macro file wherein i integrated your code, as well as the image of the error report!

    Thanks!
    Sanjeev
    Attached Images Attached Images
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to convert comma delimited csv file to excel file??

    try this change
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1