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

I have a workbook which has several worksheets.

How do I save just one particular worksheet, including the formatting,
using VBA code.

The worksheet does have references to other worksheets, within the
workbook



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Saving one specific worksheet in a workbook

A worksheet must be contained in a workbook, so you need to copy the sheet
to a new workbook and then save that new workbook. E.g.,

Worksheets("Sheet2").Copy
ActiveWorkbook.SaveAs Filename:="C:\test.xls"
ActiveWorkbook.Close False

This will create a new workbook containing only Sheet2 from the original
workbook, and then save it as C:\Test.xls and close it.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"budenba" wrote in message
...
I have a workbook which has several worksheets.

How do I save just one particular worksheet, including the formatting,
using VBA code.

The worksheet does have references to other worksheets, within the
workbook



------------------------------------------------
~~ Message posted from
http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Saving one specific worksheet in a workbook

worksheets("Sheet9").copy ' creates new single sheet workbook
ActiveWorkbook.SaveAs "C:\My Folder\Myfile.xls"
ActiveWorkbook.Close SaveChanges:=False

so what do you want to happen to the linked cells - as written, they remain
and this workbook has a link back to the original.

worksheets("Sheet9").copy
ActiveSheet.Cells.Copy ' creates new single sheet workbook
Activesheet.Cells.Pastespecial xlValues
ActiveWorkbook.SaveAs "C:\My Folder\Myfile.xls"
ActiveWorkbook.Close SaveChanges:=False

the above replaces all formulas with the value they display - no formulas,
no links.

--
Regards,
Tom Ogilvy

"budenba" wrote in message
...
I have a workbook which has several worksheets.

How do I save just one particular worksheet, including the formatting,
using VBA code.

The worksheet does have references to other worksheets, within the
workbook



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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
Copy Data from Workbook into specific Worksheet in other Workbook? kingdt Excel Discussion (Misc queries) 1 March 16th 06 06:55 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


All times are GMT +1. The time now is 09:46 AM.

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

About Us

"It's about Microsoft Excel"