Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Copy from one work to another

What im trying to do is this. I have a main work book that opens another work
book then copys a tab into the main work book. Now I have to add more then
the one tab to the 2nd work book and copy all tab to the main. Now in the 2nd
workbook it can have 1 to 5 tabs and i need to make sure i get all the tabs.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200712/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Copy from one work to another

The code below copies only the sheets that are in the 2nd workbook and not in
the main workbook

Sub copysheets()

Workbooks.Open Filename:="second.xls"
For Each second_ws In Workbooks("second.xls").Sheets
Found = False
For Each main_ws In ThisWorkbook.Sheets
If second_ws.Name = main_ws.Name Then
Found = True
Exit For
End If
Next main_ws
If Found = False Then
With ThisWorkbook
second_ws.Copy after:=.Sheets(.Sheets.Count)
End With
End If

Next second_ws
End Sub

"jln via OfficeKB.com" wrote:

What im trying to do is this. I have a main work book that opens another work
book then copys a tab into the main work book. Now I have to add more then
the one tab to the 2nd work book and copy all tab to the main. Now in the 2nd
workbook it can have 1 to 5 tabs and i need to make sure i get all the tabs.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200712/1


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
how do I copy a footer from Work to Excel SFTL Excel Discussion (Misc queries) 1 December 10th 09 11:21 PM
how do i copy a worksheet to another work book multi work book sheet copies Excel Worksheet Functions 1 July 15th 08 08:38 PM
Copy Selection doesn't work nxqviet Excel Programming 0 August 17th 07 01:07 AM
Copy + Quote - doesn't work. Yolaluvs3 Excel Discussion (Misc queries) 0 December 14th 05 10:11 PM
Can I copy the odc files and will they still work? Ron in WA Excel Programming 0 May 5th 05 05:50 PM


All times are GMT +1. The time now is 02:55 AM.

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

About Us

"It's about Microsoft Excel"