![]() |
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/ |
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/ |
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/ |
All times are GMT +1. The time now is 09:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com