Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Saving a worksheet out of a workbook

Excel 2000

Is there a programming statement that will save a worksheet out of a
workbook to a new filename?

Application.ActiveWorkbook.Sheet4.SaveCopyAs ("Coffee-A.xls")

The foregoing statement fails because the SaveCopyAs method only
supports worksbooks, not worksheets.

Thanks for any help.

Fred Holmes
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Saving a worksheet out of a workbook

Check out the Worksheet.Copy method. Note that "...If you don't specify
either Before or After, Microsoft Excel creates a new workbook that contains
the copied sheet." (and ONLY the copied sheet). You would then probably
want to loop through the Workbook collection, find the new "Book x" and then
save it with a specific file name.

Alternatively, use something like (aircode)
'Create a new workbook, keeping a handle to it.
Set wkb = Workbooks.Add
' Copy a sheet to the new workbook
MyWorksheet.Copy Befo=wkb.Worksheets("Sheet 1")
' (Optionally delete all sheets in the new Workbook except the one
you just copied)
' (Do this AFTER you copy since a workbook must have at least one
sheet)
' Give the new workbook a name by saving it.
wkb.SaveAs Filename:= "MyNewFile.xls"

HTH,
George Nicholson

Remove 'Junk' from return address.


"Fred Holmes" wrote in message
...
Excel 2000

Is there a programming statement that will save a worksheet out of a
workbook to a new filename?

Application.ActiveWorkbook.Sheet4.SaveCopyAs ("Coffee-A.xls")

The foregoing statement fails because the SaveCopyAs method only
supports worksbooks, not worksheets.

Thanks for any help.

Fred Holmes



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Saving a worksheet out of a workbook


ActiveWorkbook.Sheet4.Copy
ActiveWorkbook.SaveAs Filename:="Coffee-A.xls"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Fred Holmes" wrote in message
...
Excel 2000

Is there a programming statement that will save a worksheet out of a
workbook to a new filename?

Application.ActiveWorkbook.Sheet4.SaveCopyAs ("Coffee-A.xls")

The foregoing statement fails because the SaveCopyAs method only
supports worksbooks, not worksheets.

Thanks for any help.

Fred Holmes



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Saving a worksheet out of a workbook

Marvelous. The "Copy" method is just what I was looking for.

Thanks,

Fred Holmes

On Tue, 15 Jun 2004 14:18:22 -0500, "George Nicholson"
wrote:

Check out the Worksheet.Copy method. Note that "...If you don't specify
either Before or After, Microsoft Excel creates a new workbook that contains
the copied sheet." (and ONLY the copied sheet). You would then probably
want to loop through the Workbook collection, find the new "Book x" and then
save it with a specific file name.

Alternatively, use something like (aircode)
'Create a new workbook, keeping a handle to it.
Set wkb = Workbooks.Add
' Copy a sheet to the new workbook
MyWorksheet.Copy Befo=wkb.Worksheets("Sheet 1")
' (Optionally delete all sheets in the new Workbook except the one
you just copied)
' (Do this AFTER you copy since a workbook must have at least one
sheet)
' Give the new workbook a name by saving it.
wkb.SaveAs Filename:= "MyNewFile.xls"

HTH,
George Nicholson

Remove 'Junk' from return address.


"Fred Holmes" wrote in message
.. .
Excel 2000

Is there a programming statement that will save a worksheet out of a
workbook to a new filename?

Application.ActiveWorkbook.Sheet4.SaveCopyAs ("Coffee-A.xls")

The foregoing statement fails because the SaveCopyAs method only
supports worksbooks, not worksheets.

Thanks for any help.

Fred Holmes



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
Saving a Worksheet/Workbook with VALUES ONLY CAT Excel Discussion (Misc queries) 4 October 2nd 08 06:50 PM
Saving into 1 workbook as a different worksheet dataman777 Excel Worksheet Functions 0 August 30th 05 11:37 PM
Saving data in a worksheet within a workbook Homeuser Excel Discussion (Misc queries) 2 August 21st 05 10:49 PM
When saving workbook only the first worksheet gets saved. Debutante Excel Worksheet Functions 5 December 18th 04 01:31 AM
Saving one specific worksheet in a workbook budenba Excel Programming 2 October 31st 03 12:31 PM


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