![]() |
Copying and Pasting Worksheet between workbooks
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! |
Copying and Pasting Worksheet between workbooks
"fbagirov" wrote in message ... 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 :) |
Copying and Pasting Worksheet between workbooks
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" wrote in message ... 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 :) |
All times are GMT +1. The time now is 10:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com