copying chart from one workbook to another using VB

aretai

New Member
Joined
Aug 5, 2010
Messages
2
I'm working on a workbook and calculate some values, based on which I create a graph. There is a new workbook created earlier in my code to which i would like to paste the new graph. Some of my code

Code:
Public wbk As Workbook
    Set wbk = Workbooks.Add  ' I use this to identify the new workbook
I don't use variable wbk anywhere else but in the part where I try to copy the chart:

Code:
ActiveSheet.ChartObjects("RadarGraph").Activate 'original workbook chart
        ActiveChart.ChartArea.Copy ' here I copy the chart from original workbook
        wbk.Activate 'here I try to activate the wbk workbook - new workbook that was created earlier
        Worksheets("Results").Activate 'Here I activate the worksheet on the new workbook (it has the same name as the worksheet i was working with the original workbook
        Worksheets("Results").Paste 'here I paste the chart
This however pastes the chart back to the original workbook instead of the new one. Where is the problem.

Thank you
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,066
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Try:
Code:
        wbk.Worksheets("Results").Paste
 

Watch MrExcel Video

Forum statistics

Threads
1,122,409
Messages
5,595,973
Members
414,035
Latest member
billbumkins

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top