[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Save only one sheet from workbook

joecrabtree

12/14/2006 9:46:00 PM

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 Answers

Mike Fogleman

12/14/2006 10:25:00 PM

0

Sheets("data1").Copy

Mike F
"joecrabtree" <thejoecrabtree@gmail.com> wrote in message
news:1166132768.768186.256650@79g2000cws.googlegroups.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
>


Ron de Bruin

12/14/2006 10:26:00 PM

0

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


--

Regards Ron de Bruin
http://www.rondebruin.n...


"joecrabtree" <thejoecrabtree@gmail.com> wrote in message news:1166132768.768186.256650@79g2000cws.googlegroups.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
>

joecrabtree

12/18/2006 9:26:00 AM

0

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
<RafaelGuerreiroOso...@discussions.microsoft.com> 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 -