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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try:
Code:
        wbk.Worksheets("Results").Paste
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,656
Members
449,045
Latest member
Marcus05

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
Back
Top