+ Reply to Thread
Results 1 to 4 of 4

VBA to save multiple worksheets as separate CSV files using name of worksheet

  1. #1
    Registered User
    Join Date
    02-16-2005
    Location
    Dubai, UAE
    MS-Off Ver
    365
    Posts
    40

    VBA to save multiple worksheets as separate CSV files using name of worksheet

    Hi there,

    I need to save multiple worksheets in an excel file to individual CSV files. Right now, I am doing this manually once a week, but since there are over 30 worksheets, this is obviously quite cumbersome.
    Attached is an example of the logic.

    I have 2 "master sheets" in the workbook that do the heavy lifting of the analysis, populating the 30 worksheets with updated data, once I ran my update links etc. What I would need is some sort of VBA code that can easily save each worksheet as a CSV file in the same folder that the master file resides in, using the worksheet name as the file name, requiring no human interaction.

    Do you think that is possible?

    All worksheets that need to be exported start with the word "CSV", so that could be an automatic criteria for the macro to understand which sheets need to get exported.... I couldn't find a similar solution in the forum unfortunately, which struck me as weird, as I don't believe to have such a unique requirement. If there's anything out there already that does what I need, please post the link, it's very much appreciated!

    Best regards,
    Titus
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: VBA to save multiple worksheets as separate CSV files using name of worksheet

    Try this

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    09-20-2012
    Location
    london, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VBA to save multiple worksheets as separate CSV files using name of worksheet

    Hi Martin,

    I tried to adopt your code as my requirement was very similar. I have data in the following format per tab in excel 2010

    AC ME ACME CO
    Date PX_OPEN PX_HIGH PX_LOW PX_LAST
    27/09/2011 1108.23 1141.13 1075.33 1108.23
    28/09/2011 1130.33 1163.47 1097.19 1130.33
    29/09/2011 1145.81 1180.21 1111.40 1145.81

    i need to save each tab in excel as a .CSV file in a folder (any name will do). The number of tab's will vary - anything from 1 to N tabs. So basically the vba would need to create N CSV files. Also - as the tab data will be updated daily - i would need to overwrite the old .CSV files.

    If you can help - will be greatly appreciated.

    Many thanks


  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA to save multiple worksheets as separate CSV files using name of worksheet

    yg74,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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