Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Copy selected mulitple worksheets to mulitple new workbooks

Perhaps something like the code below, assuming the data is in Columns A and
B. Note that the "Name" property of a workbook is a read-only property and
in order for that to become "NewWB_XX", the workbook has to be saved with
that filename. Also, I have put "On Error Resume Next" to simplify and avoid
error handling. I recommend you take out that line and add appropriate error
handling.

Sub test()
Dim lRow As Long
Dim wb As Workbook

On Error Resume Next

With ThisWorkbook.Sheets("Sheet1")
lRow = 1
While .Range("A" & lRow).Text < ""
Set wb = Nothing
Set wb = Workbooks(.Range("B" & lRow).Text & ".xls")
If wb Is Nothing Then
Set wb = Workbooks.Add
wb.SaveAs .Range("B" & lRow).Text
End If
ThisWorkbook.Sheets(.Range("A" & lRow).Text).Copy
After:=wb.Sheets(wb.Sheets.Count)
lRow = lRow + 1
Wend
End With
End Sub



"Ian" wrote:

I have a master workbook with several worksheets, some of which I want to
copy to new workbooks based on a table within the original workbook

So for example, I have worksheets TSheet1, TSheet2 .... TSheet8 in a
workbook, and arelisted in a table together with the name of the NewWB that I
want them copied to ..for example :

TSheet1 NewWB_01
TSheet2 NewWB_01
TSheet3 NewWB_02
TSheet4 NewWB_03
TSheet5 NewWB_01
TSheet6 NewWB_03
TSheet7 NewWB_02
TSheet8 NewWB_01

So the result should be 3 new workbooks NewWB_01, NewWB_02, NewWB_03 which
will each contain copies of the worksheets per the above list.

The number and names of both worksheets and new workbooks will need to vary
( I have simplified them in the above example)

--
Regards & Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
When I try to click 1 cell mulitple cells are selected. Cam76 Excel Discussion (Misc queries) 1 October 13th 09 04:07 PM
Mulitple Workbooks and Ignoring Blank Cells Larry Excel Discussion (Misc queries) 5 September 8th 09 06:23 PM
Can mulitple Excel workbooks be summarized into 1 workbook? micjil Excel Discussion (Misc queries) 1 July 15th 09 08:23 PM
link to mulitple workbooks violet Excel Programming 2 November 20th 06 06:17 AM
separate data into mulitple workbooks [email protected] Excel Discussion (Misc queries) 1 July 4th 06 05:59 PM


All times are GMT +1. The time now is 01:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"