Results 1 to 3 of 3

Thread: Split Workbook In To Sheets, Export To Folder and Move File

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Split Workbook In To Sheets, Export To Folder and Move File

    Hi all - I currently have a macro that exports all "Sheets" to separate CSV's based on the sheet name (See Below for script). I would like to add a step prior to create a folder based on two cells with a "-" between such as C2-B2. The current script will create the exports within the same folder that the .XLSM file is located. I would like the script to create the new folder within parent folder where the workbook is located and then export the CSVs into that newly created folder. Also, I would like the script at the end to copy a file called "header.txt" from the parent folder into the newly created folder.

    Oh I forgot - Is there any way to prevent the export script from exporting the first sheet only?

    Any assistance is appreciated!!

    Current Export Macro---
    Code:
    Sub CSVExportTest2()
    
    Dim tmpWS As Worksheet
    Application.DisplayAlerts = False
    For Each WS In ThisWorkbook.Worksheets
    
            filePath = exportPath & "" & WS.Name & ".csv"
    
            WS.Copy
            Set tmpWS = ActiveSheet
            tmpWS.SaveAs Filename:=filePath, FileFormat:=xlCSV
            tmpWS.Parent.Close False
    Next
    
    End Sub
    Last edited by Excel Fox; 05-22-2013 at 11:50 AM. Reason: Code Tags Added

Similar Threads

  1. Replies: 6
    Last Post: 05-20-2013, 10:06 PM
  2. Replies: 7
    Last Post: 05-17-2013, 10:38 PM
  3. Replies: 7
    Last Post: 05-08-2013, 07:12 PM
  4. Replies: 1
    Last Post: 02-14-2013, 12:09 PM
  5. Find Parent Folder From Given Folder / File Path
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 1
    Last Post: 05-28-2011, 03:50 PM

Posting Permissions

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