Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Creating Individual Workbooks.
Written by Allen Wyatt (last updated March 17, 2022)
This tip applies to Excel 97, 2000, 2002, and 2003
If you use Excel quite a bit, you know you may get some rather large workbooks from colleagues. Often it is desirable to break the workbook down, so that each worksheet is in its own workbook. While this can be done manually, the process quickly becomes tedious if you have a lot of breaking down to do.
This sort of repetitive work is a natural for a macro. The following macro, called BreakItUp, creates individual workbook files based on the worksheets in the current workbook. Thus, if the current workbook contains 25 worksheets, running this macro results in 25 individual Excel workbook files being created. Each workbook has a single worksheet, and the name of the workbook is the same as that of the worksheet.
Sub BreakItUp() Dim sht As Worksheet Dim NFName As String Const WBPath = "C:\" For Each sht In ActiveWorkbook.Worksheets sht.Copy NFName = WBPath & sht.Name & ".xls" ActiveWorkbook.SaveAs FileName:=NFName, _ FileFormat:=xlNormal, CreateBackup:=False ActiveWindow.Close Next End Sub
The BreakItUp macro stores the new workbooks in the root directory on the C: drive. If you want your workbooks saved in a different place, you can simply change the line in which the WBPath constant is created.
You should also know that it is relatively easy to crash this macro. For instance, if you use a character in a worksheet name that is not "legal" for a file name, the macro will rudely stop when it tries to create the file. Of course, you could easily make the modifications to the macro to check for and replace such illegal characters.
Another potential pitfall for the macro is that it will stop running if a file already exists that has the same name as a worksheet. For instance, let's suppose you have a worksheet named MySheet1. If there is already a file on disk called MySheet1.xls, then the macro will stop when it tries to overwrite the file. You can get around this by making sure there are no file name conflicts in the directory where the workbooks are being saved.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2230) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Creating Individual Workbooks.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
If you are opening a workbook and Excel seems to hang without ever fully loading, it could be due to a number of ...
Discover MoreIf you leave your Personal.xls workbook visible from one Excel session to another, you may find that you unwittingly make ...
Discover MoreThis tip presents two techniques you can use to print multiple workbooks all at the same time. Both techniques involve ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments