PC Review


Reply
Thread Tools Rate Thread

Copy a table from one workbook to ALL worksheets in a different wb

 
 
JABAgdl
Guest
Posts: n/a
 
      16th Dec 2009
Hello Excel Gurus!

I need to copy a summary table that is in workbook "A" to all worksheets
contained in workbbok "B". Sometimes workbook "B" have 800+ worksheets. So I
tried to make a macro that would that for me as follows:

Windows("A.xlsm").Activate
Range("A1:B17").Select
Selection.Copy
Windows("B.xls").Activate

Dim Wks As Worksheet

For Each Wks In ActiveWorkbook.Worksheets

With Wks
Range("B31").Select
ActiveSheet.Paste
End With
Next Wks
Windows("A.xlsm").Activate
Range("D1").Select

However it is not working properly since it is not changing to the next
worksheet in the workbook. Can you help me with it please? By the way,
worksheet's number are not consecutive numbers, even some of them have been
renamed to a word like "Store1".

Thanks you in advance for any and all help!

JB
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      16th Dec 2009
I'd use something like:

Dim FromRng as range
dim wks as worksheet

with workbooks("a.xlsm").worksheets("What's the name of the worksheet")
set fromrng = .range("A1:b17")
end with

with workbooks("b.xls") 'is that the correct name/extension
for each wks in .worksheets
fromrng.copy _
destination:=wks.range("b31")
next wks
end with

Notice the dots in front of those ranges (and objects)--that means that they
belong to the object in the previous With statement.


JABAgdl wrote:
>
> Hello Excel Gurus!
>
> I need to copy a summary table that is in workbook "A" to all worksheets
> contained in workbbok "B". Sometimes workbook "B" have 800+ worksheets. So I
> tried to make a macro that would that for me as follows:
>
> Windows("A.xlsm").Activate
> Range("A1:B17").Select
> Selection.Copy
> Windows("B.xls").Activate
>
> Dim Wks As Worksheet
>
> For Each Wks In ActiveWorkbook.Worksheets
>
> With Wks
> Range("B31").Select
> ActiveSheet.Paste
> End With
> Next Wks
> Windows("A.xlsm").Activate
> Range("D1").Select
>
> However it is not working properly since it is not changing to the next
> worksheet in the workbook. Can you help me with it please? By the way,
> worksheet's number are not consecutive numbers, even some of them have been
> renamed to a word like "Store1".
>
> Thanks you in advance for any and all help!
>
> JB


--

Dave Peterson
 
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
Re: Copy all worksheets to another workbook, excl. duplicate sheets already in other workbook Chip Pearson Microsoft Excel Programming 0 26th May 2009 04:27 PM
Copy worksheets to a different workbook Angel C Microsoft Excel Programming 5 13th Feb 2009 04:36 PM
Copy worksheets within a workbook robert morris Microsoft Excel Misc 0 24th Feb 2008 01:25 PM
Copy worksheets to another workbook c mateland Microsoft Excel Programming 4 19th Mar 2007 03:44 AM
Copy four worksheets from one workbook into a new workbook.e-mail =?Utf-8?B?RnJhbmNpcyBCcm93bg==?= Microsoft Excel Programming 1 3rd Oct 2005 12:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:56 PM.