ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Q: save a sheet to a file (https://www.excelbanter.com/excel-discussion-misc-queries/52108-q-save-sheet-file.html)

JIM.H.

Q: save a sheet to a file
 
I use ActiveWorkbook.SaveAs destFile in a macro to save current workbook to a
n excel file, how can I save only a specific sheet in current workbook to a
file?

Dave Peterson

Q: save a sheet to a file
 
Manually, you could copy that sheet to a new workbook and save that new
workbook.

Dim Wks as worksheet
dim destFile as string

destfile = "c:\temp\myfile.xls"
set wks = activeworkbook.worksheets("Sheet99")
wks.copy 'creates a new workbook

activeworkbook.saveas destfile
activeworkbook.close savechanges:=false


JIM.H. wrote:

I use ActiveWorkbook.SaveAs destFile in a macro to save current workbook to a
n excel file, how can I save only a specific sheet in current workbook to a
file?


--

Dave Peterson

i-Zapp

Q: save a sheet to a file
 

ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:= "C:\somefilename.xls"

try using the record macro functionality. works good for stuff like
this.


--
i-Zapp
------------------------------------------------------------------------
i-Zapp's Profile: http://www.excelforum.com/member.php...fo&userid=5768
View this thread: http://www.excelforum.com/showthread...hreadid=479106



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com