+ Reply to Thread
Results 1 to 8 of 8

VBA code to split sheets and save as seperate CSV files

  1. #1
    Forum Contributor mccrimmon's Avatar
    Join Date
    02-19-2004
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    249

    VBA code to split sheets and save as seperate CSV files

    Hello

    I am wondering if anyone can help.

    I have a spreadsheet that we receive that contains 8 different sheets.

    I am looking to create a macro that splits these 8 different sheets into seperate workbooks and saves them as a CSV file?

    Thanks

    McC
    McCrimmon

  2. #2
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    This will work with up to 8 worksheets, it will name each new CSV workbook by the name of the actual worksheet being moved. It will leave the original workbook intact (As a backup, I did not want to delete sheets from the original workbook.)
    Please Login or Register  to view this content.
    Regards

    Rick
    Win10, Office 365

  3. #3
    Forum Contributor mccrimmon's Avatar
    Join Date
    02-19-2004
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    249
    Hi

    I have tried running the above code, however, nothing appears to happen?

    Any suggestions?

    Thanks again
    Much appreciated

  4. #4
    Forum Contributor mccrimmon's Avatar
    Join Date
    02-19-2004
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    249
    Hi

    Can anyone help please?

    Thanks

  5. #5
    Registered User
    Join Date
    05-28-2008
    Posts
    8

    Wink change the path

    you probably don't have a drive U: change the path for the save as command to a valid one for your environment.

    regards,
    SweetEbird

  6. #6
    Forum Contributor mccrimmon's Avatar
    Join Date
    02-19-2004
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    249
    Hi

    Thanks for getting back to me.

    I have already changed the file path to my own drive and it still does not appear to work?

    Thanks again

  7. #7
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    Please post a copy of your workbook, I may be able to offer more help.

  8. #8
    Registered User
    Join Date
    12-01-2008
    Location
    Dallas
    Posts
    1

    Better VBA Code?

    I took the above code and tweaked it a bit:

    Please Login or Register  to view this content.
    You have to distinguish the final sheet, because you cannot move a sheet out of a document if it is the only sheet. This also resolves any issues on the naming of the tabs (the prior version required that the sheets be named "Sheet3").

    I believe you weren't getting any error messages because the code suppressed those. I did not include those, because I need to know why something didn't do what I thought it would.
    I hope this helps.
    J
    Last edited by VBA Noob; 12-01-2008 at 02:41 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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