top of page

Macro to Split Up Worksheets


Here's a simple little, easy to run macro in Excel which will split up individual worksheets into separate Excel files named with the original workbook name and the worksheet name. This can be an important tool when you're processing lots of Excel files and need to run other macros on them that will on function on individual worksheets.

Sub SplitSheets() Dim W As Worksheet For Each W In Worksheets W.SaveAs ActiveWorkbook.Path & "/" & Trim(ActiveWorkbook.Name) & "_" & W.Name & ".csv", FileFormat:=xlCSV Next W End Sub

You should not have to edit this macro in any way.

We begin with a spreadsheet containing three separate worksheets, "Teams"; "HallofFame"; and "Sheet2".

Press ALT + F11 to go into Visual Basic and right click on the workbook name and insert a new module. Paste in the SplitSheets macro

Go to the View ribbon, Macros . . . View Marcos and select & run the SplitSheets macro.

As you can see in the folder in which the original spreadsheet was saved, new .csv files will be generated with the original workbook name, and then the worksheet name. However a flaw in the macro adds in the names of any preceding worksheets in the workbook. If necessary this can be remedied with a REN batch file, or the method employing Bulk Rename Utility profiled on Amy Bowser Rollins' Litigation Support Guru site.


 

Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

​

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

​

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page