Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Select Worksheets, Copy to New Workbook

I have a worksheet that is used as a processing template and then I want to
copy specified worksheets to a new file for distribution without any macros
attached. However, the code I'm using isn't working despite it being used
successfully by other posters here. Obviously, I'm doing something wrong and
would appreciate a pointer or two.

This works fine:
Sheets("NOTES").Select
Sheets("NOTES").Copy

These produce the error "Run-time error '1004' Select method of Sheets class
failed":
Attempt 1
Dim wkshts As Variant
wkshts = Array("Summary", "Deployment Profiles", "Tranche G", "Tx DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc", _
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents", _
"Deployment Cancellations", "Terminology", "DL", "Calculations")
Sheets(wkshts).Select
Sheets(wkshts).Copy

Attempt 2
'Sheets(Array("NOTES", "Summary", "Deployment Profiles", "Tranche G",
"Tx DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc", _
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents" _
, "Deployment Cancellations", "Terminology", "DL",
"Calculations")).Select
'Sheets(Array("NOTES", "Summary", "Deployment Profiles", "Tranche G",
"Tx DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc", _
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents" _
, "Deployment Cancellations", "Terminology", "DL",
"Calculations")).Copy

I'm guessing Sheets doesn't like Array very much but as the former was
posted a while ago as an accepted solution to a problem and the latter was
what the macro recorder gave me, I'm a little confused and at a loss as to
what to do.

All suggestions gratefully received!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Select Worksheets, Copy to New Workbook


myarray=
for each ws in myarray
ws.copy
next

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ladymuck" wrote in message
...
I have a worksheet that is used as a processing template and then I want to
copy specified worksheets to a new file for distribution without any
macros
attached. However, the code I'm using isn't working despite it being used
successfully by other posters here. Obviously, I'm doing something wrong
and
would appreciate a pointer or two.

This works fine:
Sheets("NOTES").Select
Sheets("NOTES").Copy

These produce the error "Run-time error '1004' Select method of Sheets
class
failed":
Attempt 1
Dim wkshts As Variant
wkshts = Array("Summary", "Deployment Profiles", "Tranche G", "Tx
DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc",
_
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents", _
"Deployment Cancellations", "Terminology", "DL", "Calculations")
Sheets(wkshts).Select
Sheets(wkshts).Copy

Attempt 2
'Sheets(Array("NOTES", "Summary", "Deployment Profiles", "Tranche G",
"Tx DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc",
_
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents" _
, "Deployment Cancellations", "Terminology", "DL",
"Calculations")).Select
'Sheets(Array("NOTES", "Summary", "Deployment Profiles", "Tranche G",
"Tx DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc",
_
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents" _
, "Deployment Cancellations", "Terminology", "DL",
"Calculations")).Copy

I'm guessing Sheets doesn't like Array very much but as the former was
posted a while ago as an accepted solution to a problem and the latter was
what the macro recorder gave me, I'm a little confused and at a loss as to
what to do.

All suggestions gratefully received!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Select Worksheets, Copy to New Workbook

Dim wkshts As Variant
wkshts = Array("Summary", "Deployment Profiles", _
"Tranche G", "Tx DSMP", "T4 BHFS Deployments", _
"Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc", _
"Incident Profile", "Outstanding Incidents", _
"Problem Records", "Master Incidents", _
"Deployment Cancellations", "Terminology", "DL", "Calculations")

Set newbk = Workbooks.Add
For Each sht In wkshts
With newbk
ThisWorkbook.Sheets(sht).Copy _
Destination:=.Sheets(.Sheets.Count)
End With
Next sht
Do
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Text Files (*.xls), *.xls")
If fileSaveName = False Then
MsgBox ("Cannot Save file")
End If
Loop While fileSaveName = False
nexbk.SaveAs Filename:=fileSaveName


"Don Guillett" wrote:


myarray=
for each ws in myarray
ws.copy
next

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ladymuck" wrote in message
...
I have a worksheet that is used as a processing template and then I want to
copy specified worksheets to a new file for distribution without any
macros
attached. However, the code I'm using isn't working despite it being used
successfully by other posters here. Obviously, I'm doing something wrong
and
would appreciate a pointer or two.

This works fine:
Sheets("NOTES").Select
Sheets("NOTES").Copy

These produce the error "Run-time error '1004' Select method of Sheets
class
failed":
Attempt 1
Dim wkshts As Variant
wkshts = Array("Summary", "Deployment Profiles", "Tranche G", "Tx
DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc",
_
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents", _
"Deployment Cancellations", "Terminology", "DL", "Calculations")
Sheets(wkshts).Select
Sheets(wkshts).Copy

Attempt 2
'Sheets(Array("NOTES", "Summary", "Deployment Profiles", "Tranche G",
"Tx DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc",
_
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents" _
, "Deployment Cancellations", "Terminology", "DL",
"Calculations")).Select
'Sheets(Array("NOTES", "Summary", "Deployment Profiles", "Tranche G",
"Tx DSMP", _
"T4 BHFS Deployments", "Tx Non-DSMP", "DSMP Adhoc", "Other Adhoc",
_
"Incident Profile", "Outstanding Incidents", "Problem Records",
"Master Incidents" _
, "Deployment Cancellations", "Terminology", "DL",
"Calculations")).Copy

I'm guessing Sheets doesn't like Array very much but as the former was
posted a while ago as an accepted solution to a problem and the latter was
what the macro recorder gave me, I'm a little confused and at a loss as to
what to do.

All suggestions gratefully received!



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 select all worksheets in a workbook Faith Excel Discussion (Misc queries) 8 October 20th 08 09:12 PM
Protecting select group of worksheets within a workbook Audrey G. Excel Worksheet Functions 0 July 8th 08 06:16 PM
Open Workbook Read Only and hide select worksheets imelda1ab Excel Programming 10 March 27th 08 02:33 PM
select all worksheets in a workbook jhahes[_73_] Excel Programming 2 August 10th 06 03:47 AM
Select a range and copy to new workbook juan Excel Programming 0 July 23rd 04 11:53 PM


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