Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Save only one sheet from workbook

Hi all,

I have a workbook with lots of worksheets, but as part of my macro I
want to just save the sheet named data1 as a new file. Is there any
easy way that I can do this?

Thanks in advance,

Joseph Crabtree

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Save only one sheet from workbook

Sheets("data1").Copy

Mike F
"joecrabtree" wrote in message
ups.com...
Hi all,

I have a workbook with lots of worksheets, but as part of my macro I
want to just save the sheet named data1 as a new file. Is there any
easy way that I can do this?

Thanks in advance,

Joseph Crabtree



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Save only one sheet from workbook

You can use this example in 97-2007
http://www.rondebruin.nl/security.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"joecrabtree" wrote in message ups.com...
Hi all,

I have a workbook with lots of worksheets, but as part of my macro I
want to just save the sheet named data1 as a new file. Is there any
easy way that I can do this?

Thanks in advance,

Joseph Crabtree

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Save only one sheet from workbook

Hi

Thats great.

I now want to be able to save all charts in the workbook as a seperate
file. All chart sheets have the name chart1, chart2 etc. Is there
anyway of modifying the codee to do this?

Thanks

Joseph


On Dec 14, 10:15 pm, Rafael Guerreiro Osorio
wrote:
Add the sub CopyToNewWBKandSave and then call it from your code as I did in
sub Test below, supplying it with three arguments, the worksheet object that
refers to data1, a string containing the path to the folder in which you the
new workbook to be saved, and other with the name to be given to the new file

Sub Test()
Dim WKS As Worksheet
Dim SavePath, SaveName As String

'Worksheet object data1
Set WKS = ThisWorkbook.Worksheets("data1")

'Save path & name
SavePath = "C:\"
SaveName = "DataFile.xls"

'Add this line to your macro...
CopyToNewWBKandSave WKS, SavePath, SaveName
End Sub

'...and the sub below as well.
Private Sub CopyToNewWBKandSave(ByRef ToSave As Worksheet, ByVal sPath,
sName As String)
Dim NewWBK As Workbook

ToSave.Copy
Set NewWBK = Workbooks(Workbooks.Count)
NewWBK.SaveAs sPath & sName
End Sub

Best,

R.



"joecrabtree" wrote:
Hi all,


I have a workbook with lots of worksheets, but as part of my macro I
want to just save the sheet named data1 as a new file. Is there any
easy way that I can do this?


Thanks in advance,


Joseph Crabtree- Hide quoted text -- Show quoted text -


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
Please help! When I 'save changes' to my workbook/sheet V Excel Discussion (Misc queries) 0 May 18th 09 10:22 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Can I only save one sheet out of the workbook? PeterM Excel Discussion (Misc queries) 4 September 1st 05 04:42 AM
how to save only one sheet as workbook Kiknadze Lado Excel Programming 2 August 18th 04 11:24 AM
Save sheet as .TXT out of Workbook goepf[_8_] Excel Programming 13 December 15th 03 04:10 PM


All times are GMT +1. The time now is 08:58 PM.

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"