LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy all worksheets to another workbook, excl. duplicate sheets already in other workbook


Hi all!

I must say that this forum has been helpful in leaps and bounds!

Anyways, I have code that cycles through all sheets in workbook1, and
then copies a specific range to the corresponding worksheets (with like
names) in workbook2. [PHASE 1]

Now my problem is that I need code that will cycle through all
worksheets in workbook1, and compare the names of them to those in
workbook2. If a worksheet (i.e. worksheet name) exists in the first
workbook, but not in the second workbook, then this specific sheet
(including all formulas, formats etc.) in its entirety must be copied to
the second workbook...[PHASE 2]

Bear in mind that an indefinite number of worksheets will be added over
time (into workbook1), of which the sheet names will be unknown (i.e. I
may not use specific sheet names in the macro (i.e worksheets
("ListA").Copy, etc. can not be used. ALSO, The amount of sheets
workbook1 is unknown.

Makes sense?
If it does, please help!!!
SOS
:)

Here's the code I've got for the first phase:

Sub Copy_Stuff ()

Dim TargetWB As Workbook
Dim SourceWB As Workbook
Dim TargetWS As Worksheet
Dim SourceWS As Worksheet
Dim SourceRange As Range

Set TargetWB = Workbooks.Open(ThisWorkbook.Path & "\Price Lists1.xlsm",
ignorereadonlyrecommended:=True)

Set SourceWB = Workbooks.Open(ThisWorkbook.Path & "\Price Lists2.xlsm",
ignorereadonlyrecommended:=True)


Workbooks("Price Lists2.xlsm").Activate
For Each SourceWS In Worksheets
Set SourceRange = SourceWS.Range("C13:X100")

Workbooks("Price Lists1.xlsm").Activate
For Each TargetWS In Worksheets
If TargetWS.Name = SourceWS.Name Then
SourceRange.Copy
TargetWS.Range("C13").PasteSpecial xlPasteAll

'PLACE NEW CODE HERE...??? after ELSE
statement...???

Exit For
End If
Next TargetWS
Next SourceWS

Set TargetWB = Nothing
Set SourceWB = Nothing
Set SourceRange = Nothing

End Sub

Any Idea of code I can use for phase 2 in the ['PLACE NEW CODE
HERE...??? after ELSE statement...???] area?

Any other suggestions are also welcome.

Thanx in advance...
ARbitOUR


--
ARbitOUR
------------------------------------------------------------------------
ARbitOUR's Profile: http://www.thecodecage.com/forumz/member.php?userid=254
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=100430

 
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 duplicate value in multiple worksheets in same workbook? jwnorris Excel Discussion (Misc queries) 3 December 4th 05 08:01 PM
copy sheets in workbook to new workbook Ctech[_56_] Excel Programming 1 November 23rd 05 08:09 PM
Copy four worksheets from one workbook into a new workbook.e-mail Francis Brown Excel Programming 1 October 3rd 05 12:24 AM
how do i look through worksheets in a workbook to find duplicate Connie Excel Worksheet Functions 1 June 25th 05 05:10 PM
copy a workbook from other workbook with lot of sheets wit... Vai Excel Discussion (Misc queries) 1 January 3rd 05 10:27 PM


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

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"