Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AK AK is offline
external usenet poster
 
Posts: 56
Default Moving worksheet

Please help:-

There are 2 workbooks and I want to move all the sheets(except the sheet
with name ="Sheet1", "Sheet2"...) in "Workbook A" to "Workbook B", how can I
write in VB?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Moving worksheet

Dear AK,

Here is one way to do it:

Sub movesheets()
Dim ws As Worksheet
Dim wbs As Workbook
Dim wbd As Workbook

Set wbs = Workbooks("Workbook A.xls")
Set wbd = Workbooks("Workbook B.xls")

For Each ws In wbs.Worksheets
If Not (ws.Name = "Sheet1" Or ws.Name = "Sheet2") Then
ws.Move after:=wbd.Worksheets(wbd.Worksheets.Count)
End If
Next ws
Set ws = Nothing
Set wbs = Nothing
Set wbd = Nothing
End Sub

--
HTHs Martin


"ak" wrote:

Please help:-

There are 2 workbooks and I want to move all the sheets(except the sheet
with name ="Sheet1", "Sheet2"...) in "Workbook A" to "Workbook B", how can I
write in VB?

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
Moving within the worksheet ordnance1 Excel Worksheet Functions 3 March 28th 08 03:45 AM
Moving a Worksheet jpiseler Excel Discussion (Misc queries) 6 September 6th 07 01:10 AM
moving a worksheet..? Roy Excel Discussion (Misc queries) 2 September 29th 06 02:56 AM
Moving worksheet Joe Excel Programming 2 March 4th 06 10:30 PM
Need help i moving one worksheet to another psk[_7_] Excel Programming 1 November 12th 04 04:00 PM


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