Chart Copy, Activate and Change Data Source

Mr. Wizard

Board Regular
Joined
Sep 28, 2005
Messages
67
I am using Excel 2007.
I have a chart with complex formatting that the users of my spreadsheet cannot make themselves. I would like to use a macro to copy the existing chart which is embedded in a spreadsheet, and copy it and the surrounding cells to another worksheet tab, select the chart and then select another data range so that it reflects the user's data rather than the dummy data I used to build the original chart.

My problem is that whenever I generate new charts using this method, I cannot determine the chart name identifier to use to select the chart.


My current method is to select the range of cells containing the data and the chart, and copy it to another range of cells where I paste in the user's data. But in doing this the macro gets lost if I cannot identify the chart name explicitly since the user may also have made other charts.

Is there a way to determine what a chart name will be when it is created by pasting a copy of the chart?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
The chart just pasted is the last chart on the sheet. It's activesheet.chartobjects(activesheet.chartobjects.count).chart

Activate it like so:

Code:
activesheet.chartobjects(activesheet.chartobjects.count).chart.chartarea.select
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,794
Members
452,943
Latest member
Newbie4296

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