Solved

macro to save each worksheet in the master workbook to new workbook

Posted on 2013-11-06
2
525 Views
Last Modified: 2013-11-07
Hi Expert's
using excel 2003

I need a macro which when run from worksheet "main"..and workbook master and copies and pastes each worksheets into a new workbook deleting sheets 2 & 3..and saves the workbook as an .xls file with the same names as the tab name being copied and lgnores worksheet "main"

the master file is stored at file path c:\my documents\team\mi\exceptions
and new files saved to c:\my documents\team\mi\new
0
Comment
Question by:route217
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39627372
Copy this to your master workbook, and run it from there.

Sub SplitWorkbook()
    Dim sht As Worksheet
    For Each sht In ThisWorkbook.Sheets
        If sht.Name <> "main" Then
            sht.Copy
            With ActiveSheet.Cells
                .Copy
                .PasteSpecial Paste:=xlPasteValues
                .PasteSpecial Paste:=xlPasteFormats
            End With
            ActiveWorkbook.SaveAs Filename:="C:\my documents\team\mi\new\" & sht.Name & ".xls"
            ActiveWorkbook.Close savechanges:=False
        End If
    Next sht
End Sub

Open in new window

0
 

Author Comment

by:route217
ID: 39629579
Hi macroshadow

thanks for the feedback and apologise for the delay.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question