PC Review


Reply
Thread Tools Rate Thread

Copy from one work to another

 
 
jln via OfficeKB.com
Guest
Posts: n/a
 
      7th Dec 2007
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 With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      7th Dec 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy work sheet to another work book, pros and cons Withnails Microsoft Excel Programming 1 21st Oct 2009 01:12 PM
How do I copy work from one label to another? Trudi Microsoft Word New Users 2 26th May 2009 08:58 AM
How does copy work? =?Utf-8?B?RmFyYnVuY2xl?= Windows Vista Hardware 5 29th Mar 2007 11:20 AM
have to copy twice to get copy paste to work =?Utf-8?B?ZXdlZW4=?= Windows XP General 2 13th Jul 2006 03:14 AM
ny copy does not work Evelyn Ballantyne Microsoft Access Getting Started 4 19th Sep 2003 10:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:30 AM.