Solved

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

Posted on 2013-11-06
2
513 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

772 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