Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Copy thru VBA

Hi: I create a new workbook. How to i copy all the sheets from my old
workbook into my new work book. I mean when ever i open my new work
book all of the sheets no i am sorry from sheet1 to sheet10 will be
copy into my new work book will all of the formulas. I am sorry i ask
this question before but i need only to copy some of the sheets not all
of them.

Thanks,

Anna.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Copy thru VBA

The easy way is to SaveAs a different file name and then delete the sheets
you don't need.

If you want to copy only the formulas, without the data content in the
cells, then add the new workbook and use copy paste special xlFormulas
for each sheet you want to be in the new workbook. You can select the entire
sheet to copy by clicking in the cell to the left or column A and above row
1, then select A1 on the sheet that you want to paste to. For only ten
sheets, the copy and paste is also easy.

"Anna" wrote:

Hi: I create a new workbook. How to i copy all the sheets from my old
workbook into my new work book. I mean when ever i open my new work
book all of the sheets no i am sorry from sheet1 to sheet10 will be
copy into my new work book will all of the formulas. I am sorry i ask
this question before but i need only to copy some of the sheets not all
of them.

Thanks,

Anna.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Copy thru VBA

This is untested and probably needs a lot of touch up, but it gives you an
idea of what the VBA code would look like. Since there is no way to know if
the worksheets you want to copy are contiguous, this code assumes they are.


Sub CpyWkb()

Set NewBook = Workbooks.Add
With NewBook
.Title = "MyNewWkBk"
.Subject = "MySubj"
.SaveAs Filename:="MyFileName.xls"
End With
Counter = 1
Do While Counter < 8

Set newSheet = Sheets.Add(After:= Worksheets(GetLastSheet)Type:=xlWorksheet )

Loop

Set Wkb = Workbooks("MyOldWkBk.xls")
For i = 1 To 10
For each sheet in Wkb
Worksheets(i).Copy Workbooks("MyNewWkBk.xls")
After:=Worksheets"(GetLastSheet)
Next

End Sub


"Anna" wrote:

Hi: I create a new workbook. How to i copy all the sheets from my old
workbook into my new work book. I mean when ever i open my new work
book all of the sheets no i am sorry from sheet1 to sheet10 will be
copy into my new work book will all of the formulas. I am sorry i ask
this question before but i need only to copy some of the sheets not all
of them.

Thanks,

Anna.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Copy thru VBA

Open the two workbooks.
On the original workbook hold down the Ctrl Key & left click on the tabs you
want to copy/move
When you have them all Right click on one of them, select "Move or Copy",
select the "To book" and put a check mark in "Create a copy" if thats what
you want.
--
Mike Q.


"Anna" wrote:

Hi: I create a new workbook. How to i copy all the sheets from my old
workbook into my new work book. I mean when ever i open my new work
book all of the sheets no i am sorry from sheet1 to sheet10 will be
copy into my new work book will all of the formulas. I am sorry i ask
this question before but i need only to copy some of the sheets not all
of them.

Thanks,

Anna.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Copy thru VBA

Hi: i try to refine the code is this is correct. Also where i copy that
function in old or the new work book also how to i call that function?

Sub CpyWkb()
Dim NewBook as Workbook, Wkb as Workbook, wks as Worksheet
Set NewBook = Workbooks.Add
With NewBook
.Title = "MyNewWkBk"
.Subject = "MySubj"
.SaveAs Filename:="C:\webpages\MyFileName.xls" '<------- path
here
End With
Set Wkb = Workbooks("MyOldWkBk.xls")
For each wks in Wkb.worksheets
wks.Copy After:=NewBook.Worksheets(NewBook.Worksheets.Count )
Next
End Sub

Thanks,
Anna.

JLGWhiz wrote:
This is untested and probably needs a lot of touch up, but it gives you an
idea of what the VBA code would look like. Since there is no way to know if
the worksheets you want to copy are contiguous, this code assumes they are.


Sub CpyWkb()

Set NewBook = Workbooks.Add
With NewBook
.Title = "MyNewWkBk"
.Subject = "MySubj"
.SaveAs Filename:="MyFileName.xls"
End With
Counter = 1
Do While Counter < 8

Set newSheet = Sheets.Add(After:= Worksheets(GetLastSheet)Type:=xlWorksheet )

Loop

Set Wkb = Workbooks("MyOldWkBk.xls")
For i = 1 To 10
For each sheet in Wkb
Worksheets(i).Copy Workbooks("MyNewWkBk.xls")
After:=Worksheets"(GetLastSheet)
Next

End Sub


"Anna" wrote:

Hi: I create a new workbook. How to i copy all the sheets from my old
workbook into my new work book. I mean when ever i open my new work
book all of the sheets no i am sorry from sheet1 to sheet10 will be
copy into my new work book will all of the formulas. I am sorry i ask
this question before but i need only to copy some of the sheets not all
of them.

Thanks,

Anna.



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
Copy and paste versus copy and insert copied cells Alana New Users to Excel 1 September 28th 07 08:58 PM
A visual basic value copy BUG?? - accounting format has copy problem!! [email protected] Excel Programming 3 June 20th 06 04:42 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
copy formulas from a contiguous range to a safe place and copy them back later Lucas Budlong Excel Programming 2 February 22nd 06 08:26 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"