Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default copying multiple worksheets to a new workbook

Hi

I have a file called myfile.xls. It contains five worksheets, sheeta,
sheetb, sheetc, sheetd, and sheete. I would like to copy the last four sheets
to a new workbook, test.xls. Is there any way this is possible using VBA?

thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default copying multiple worksheets to a new workbook

If this is a one time deal, it's quicker to do it manually. You can do it in
much less time than you can code it up.

But for VBA code, I'll tell you
#1 - yes it can be done
#2 - best way to learn how is to use the Record New Macro feature and record
what happens when you actually do it.

Examine the code created with the macro (user [Alt]+[F11] to get to the VB
Editor) to see what would need to be changed (names of workbooks involved and
names of sheets involved) to make it a more general purpose routine.

P.S. this is one good way to learn a little basic VBA coding - record macros
and examine the code generated. The bad part about recording macros is that
it doesn't do things like IF...Then and looping. Those and some other
things, you have to learn on your own.

"Shabbir" wrote:

Hi

I have a file called myfile.xls. It contains five worksheets, sheeta,
sheetb, sheetc, sheetd, and sheete. I would like to copy the last four sheets
to a new workbook, test.xls. Is there any way this is possible using VBA?

thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default copying multiple worksheets to a new workbook

One way, perhaps

Sub Macro1()
Dim count As Long

count = Sheets.count
Sheets(Array(count - 3, _
count - 2, count - 1, count)).Copy
ActiveWorkbook.Close savechanges:=True, _
Filename:="I:\Excel\Test"

End Sub


"Shabbir" wrote:

Hi

I have a file called myfile.xls. It contains five worksheets, sheeta,
sheetb, sheetc, sheetd, and sheete. I would like to copy the last four sheets
to a new workbook, test.xls. Is there any way this is possible using VBA?

thanks in advance.

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
Print all charts in a workbook (multiple worksheets) aewsaws Charts and Charting in Excel 4 May 12th 23 03:45 AM
adjusting columns in multiple worksheets of workbook with one step carole Excel Discussion (Misc queries) 2 July 8th 06 03:07 AM
Copying data to multiple worksheets by Macro lqfong Excel Discussion (Misc queries) 0 June 26th 06 03:57 AM
Viewing multiple rows of worksheets in a workbook Huber57 Excel Discussion (Misc queries) 2 March 13th 06 01:07 AM
How do I insert something on multiple worksheets in one workbook? carrie Excel Worksheet Functions 1 May 18th 05 06:31 PM


All times are GMT +1. The time now is 04:29 PM.

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"