PC Review


Reply
Thread Tools Rate Thread

Copying and Pasting Worksheet between workbooks

 
 
=?Utf-8?B?ZmJhZ2lyb3Y=?=
Guest
Posts: n/a
 
      15th Mar 2007
Got workbook A with 2 sheets (A1 and A2). A2 has tables, and A1 has charts
that are based on the tables in A2.

I need to write a macro, that will create a new workbook (B), will copy A2,
paste it into B, then copy A1 and paste it into B, before B.A2, and
recalculate Charts in B.A1 based on tables in B.A2.

What macro do I need to write ? Thanks!
 
Reply With Quote
 
 
 
 
N10
Guest
Posts: n/a
 
      16th Mar 2007

"fbagirov" <(E-Mail Removed)> wrote in message
news:94875AD6-AE31-46D2-8763-(E-Mail Removed)...
> Got workbook A with 2 sheets (A1 and A2). A2 has tables, and A1 has charts
> that are based on the tables in A2.
>
> I need to write a macro, that will create a new workbook (B), will copy
> A2,
> paste it into B, then copy A1 and paste it into B, before B.A2, and
> recalculate Charts in B.A1 based on tables in B.A2.
>
> What macro do I need to write ? Thanks!


Have you tried the macro recorder to get an idea of the code
required..thatmight be a good starting point.

Best

N10


 
Reply With Quote
 
=?Utf-8?B?ZmJhZ2lyb3Y=?=
Guest
Posts: n/a
 
      16th Mar 2007
Yes, I've done that.
This code did not work :

Sub CopyWorkbooks()

Dim WS1 as Worksheet
DIM WS2 as Worksheet
DIM WBNew as Workbook

Set WS1 = Sheets("A1")
Set WS2 = Sheets("A2")

'do something

Set WBNew=Workbooks.Add
With WBNew
.Title = B
End With

'do paste of tables from sheet A2
.....

'Paste the whole sheet A1 into B - DOES NOT WORK
WS1.Copy
WBNew.Sheets.Add
WS1.Paste

End Sub


I am confused about references to workbooks A1 and A2. I don't know how many
workbooks are going to be open on user's desktop, so I can't refer to them as
Workbooks(1), workbooks(2), etc.



"N10" wrote:

>
> "fbagirov" <(E-Mail Removed)> wrote in message
> news:94875AD6-AE31-46D2-8763-(E-Mail Removed)...
> > Got workbook A with 2 sheets (A1 and A2). A2 has tables, and A1 has charts
> > that are based on the tables in A2.
> >
> > I need to write a macro, that will create a new workbook (B), will copy
> > A2,
> > paste it into B, then copy A1 and paste it into B, before B.A2, and
> > recalculate Charts in B.A1 based on tables in B.A2.
> >
> > What macro do I need to write ? Thanks!

>
> Have you tried the macro recorder to get an idea of the code
> required..thatmight be a good starting point.
>
> Best
>
> N10
>
>
>

 
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
Copying and Pasting Macro from one worksheet to another Neil Holden Microsoft Excel Programming 2 27th Jul 2009 05:17 PM
Copying and Pasting between Two workbooks cardan Microsoft Excel Programming 2 30th Apr 2007 07:10 PM
Need to Improve Code Copying/Pasting Between Workbooks =?Utf-8?B?RGF2aWQ=?= Microsoft Excel Misc 1 6th Jan 2006 03:56 AM
Copying and Pasting a Worksheet Jim Pockmire Microsoft Excel Setup 1 8th Sep 2005 02:57 PM
Copying worksheet and pasting on new worksheet, it makes page bre =?Utf-8?B?ZXhjZWwgcXVlc3Rpb24=?= Microsoft Excel Worksheet Functions 2 24th Oct 2004 12:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:12 PM.