Saving one specific worksheet in a workbook

  • Thread starter Thread starter budenba
  • Start date Start date
B

budenba

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
 
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 (e-mail address removed)
 
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.
 
Back
Top