Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Moving multiple worksheets to new workbook in VBA

Hi,

I have an existing workbook called wb1 containing 3 worksheets; ws1 -
3. I currently use a macro which extracts a subset of rows from ws1-3
and creates a new worksheet for each. Each worksheet is moved to a new
workbook using Worksheet.Move but this creates a new workbook each time
which is not desirable.

Is there a way to create new sheets and move them to the same workbook?


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving multiple worksheets to new workbook in VBA

Move has a before/after argument. If you specify a workbook using this
argument, then you can move your sheets to an existing workbook.

--
Regards,
Tom Ogilvy

"dororke" wrote in message
...
Hi,

I have an existing workbook called wb1 containing 3 worksheets; ws1 -
3. I currently use a macro which extracts a subset of rows from ws1-3
and creates a new worksheet for each. Each worksheet is moved to a new
workbook using Worksheet.Move but this creates a new workbook each time
which is not desirable.

Is there a way to create new sheets and move them to the same workbook?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving multiple worksheets to new workbook in VBA

Move has a before/after argument. If you specify a workbook using this
argument, then you can move your sheets to an existing workbook.

--
Regards,
Tom Ogilvy

"dororke" wrote in message
...
Hi,

I have an existing workbook called wb1 containing 3 worksheets; ws1 -
3. I currently use a macro which extracts a subset of rows from ws1-3
and creates a new worksheet for each. Each worksheet is moved to a new
workbook using Worksheet.Move but this creates a new workbook each time
which is not desirable.

Is there a way to create new sheets and move them to the same workbook?


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Moving multiple worksheets to new workbook in VBA

Hi,

Yes I'm aware it does but I have tried using these to no avail. But I
believe the before and after fields actually apply to the worksheets
you want to move before/after and not the workbook.

Can you provide some sample VBA to demonstrate?

Thanks,
Dan


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving multiple worksheets to new workbook in VBA

Assume I have two workbooks, Bk1.xls and bk2.xls, both open in excel, the
code is in Bk1.xls and I am moving worksheets(1) in bk1.xls to the end of
the tab order in bk2.xls


Workbooks("bk1.xls").Worksheets(1).Move After:= _
Workbooks("bk2.xls").Worksheets( _
Workbooks("bk2.xls").Worksheets.count)

or
With workbooks("Bk2.xls")
Workbooks("bk1.xls").Worksheets(1).Move After:= _
.Worksheets(.Worksheets.count)
End With


As you can see, it refers to a worksheet in a specific workbook.

Regards,
Tom Ogilvy


"dororke" wrote in message
...
Hi,

Yes I'm aware it does but I have tried using these to no avail. But I
believe the before and after fields actually apply to the worksheets
you want to move before/after and not the workbook.

Can you provide some sample VBA to demonstrate?

Thanks,
Dan


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Moving multiple worksheets to new workbook in VBA

Hi,

Thank you very much. It worked a treat.

Dan


---
Message posted from http://www.ExcelForum.com/

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Moving multiple worksheets to new workbook in VBA

Hi,

Thank you very much. It worked a treat.

Dan


---
Message posted from http://www.ExcelForum.com/

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
Combine worksheets in multiple workbook in one workbook with a macro Sam Commar Excel Discussion (Misc queries) 2 April 2nd 09 01:09 PM
Moving multiple worksheets as separate files Poli Excel Discussion (Misc queries) 4 January 21st 09 12:35 AM
Moving worksheets to new workbook wally New Users to Excel 3 February 26th 08 03:33 AM
Combine multiple workbooks into 1 workbook w/ multiple worksheets buffgirl71 Excel Discussion (Misc queries) 1 May 13th 06 12:28 PM
Combine multiple workbooks into 1 workbook w/ multiple worksheets buffgirl71 Excel Discussion (Misc queries) 2 May 12th 06 10:30 PM


All times are GMT +1. The time now is 02:43 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"