Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Copy a collection into a new workbook.

I have selected about 20 sheets, and cannot figure out how to move
them into my new workbook

Dim colWks As New Collection
Dim wkSht As Worksheet
Dim i As Long
With Workbooks("P017_procDepByOfficer.xls")
.Activate
For Each wkSht In .Worksheets
If wkSht.Name < "Documentation" Then colWks.Add wkSht
Next wkSht
If colWks.Count 0 Then
colWks(1).Select
For i = 2 To colWks.Count
colWks(i).Select False
Next i
End If
End With

How do I reference the above collection of 20 sheets and paste into a
new workbook; here is what I am working with that is erroring out on
me.

Dim WB1 As Workbook
Dim WB2 As Workbook
Dim strSavePath As String

Set WB1 = Workbooks("P017_procDepByOfficer.xls")
Set WB2 = Workbooks.Add

Sheets(colWks).Copy Befo=WB2.Sheets(1) '--this line is what I
am trying to reference!
Columns("A:I").Select
Columns("A:I").EntireColumn.AutoFit

Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sample",
Me.EOM)).Select
Sheets("Sheet3").Activate
ActiveWindow.SelectedSheets.Delete

Thanks for your help, and let me know if you have questions.
Devon

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Copy a collection into a new workbook.

On Feb 9, 1:18 pm, "schaapiee" wrote:
I have selected about 20 sheets, and cannot figure out how to move
them into my new workbook

Dim colWks As New Collection
Dim wkSht As Worksheet
Dim i As Long
With Workbooks("P017_procDepByOfficer.xls")
.Activate
For Each wkSht In .Worksheets
If wkSht.Name < "Documentation" Then colWks.Add wkSht
Next wkSht
If colWks.Count 0 Then
colWks(1).Select
For i = 2 To colWks.Count
colWks(i).Select False
Next i
End If
End With

How do I reference the above collection of 20 sheets and paste into a
new workbook; here is what I am working with that is erroring out on
me.

Dim WB1 As Workbook
Dim WB2 As Workbook
Dim strSavePath As String

Set WB1 = Workbooks("P017_procDepByOfficer.xls")
Set WB2 = Workbooks.Add

Sheets(colWks).Copy Befo=WB2.Sheets(1) '--this line is what I
am trying to reference!
Columns("A:I").Select
Columns("A:I").EntireColumn.AutoFit

Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sample",
Me.EOM)).Select
Sheets("Sheet3").Activate
ActiveWindow.SelectedSheets.Delete

Thanks for your help, and let me know if you have questions.
Devon


Forget it, I just used sheets.copy and it worked..dont use a
collection to select worksheets.

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
How to copy workbook? LF Excel Worksheet Functions 18 December 1st 06 09:52 AM
copy pivot table and source from workbook 1 to 2. dakotasteve Excel Discussion (Misc queries) 0 September 27th 06 06:05 PM
How do I copy a cell + it's formula from one workbook to another? excel _ help for the hopeless, please Excel Discussion (Misc queries) 4 October 11th 05 11:48 PM
Copy tabs(sheets) from workbook without link to original source Rich Ulichny Excel Discussion (Misc queries) 3 August 25th 05 02:11 AM
What's the simplest way to copy data from another workbook JohnT Excel Worksheet Functions 0 January 16th 05 01:19 AM


All times are GMT +1. The time now is 06:47 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"