View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Macro to Copy Mulitple Worksheets to New Multiple Workbooks

I have to leave. this code does most of your needs. I think it works, but
don't have time to fully test. Let me know the results. To run code
highlight the cells A2:B6 then run macro

Sub copyworkbook()

Const MyPath = "c:\temp\"

Set MyRange = ActiveCell
Set OldWorkbook = ThisWorkbook

firstRow = MyRange.Row
Lastrow = MyRange.End(xlDown).Row

For RowCount = firstRow To Lastrow
OldWorkbook.Worksheets("sheet1").Activate
Myworksheet = Cells(RowCount, 1)
MyWorkbook = Cells(RowCount, 2)

Set NewBook = Workbooks.Add
On Error Resume Next
NewBook.SaveAs Filename:=MyPath + MyWorkbook

Workbooks(MyWorkbook).Sheets.Add
ActiveSheet.Name = Myworksheet

OldWorkbook.Worksheets(Myworksheet).Copy
MyWorkbook.Worksheets(Myworksheet).Paste

Workbooks(MyWorkbook).Close
Next RowCount

End Sub


"Ian" wrote:

I need some help creating a macro that will create new workbooks from a
defined list of selected worksheets in master workbook.

Example is explained below, based on the following table in cells A1:B6,
with range called List_WSName in A2:A6

Wsheet Name New Workbook Name
WSheet01 NewWB01
WSheet02 NewWB01
WSheet03 NewWB02
WSheet04 NewWB03
WSheet05 NewWB02

so based on the above data, the macro should create 3 new workbooks :
(1) NewWB01 would contain copies of WSheet01 & WSheet02
(2) NewWB02 --------------"------------ WSheet03 & WSheet05
(3) NewWb03 --------------"------------ WSheet04

Any help greatly appreciated

Thanks