generating Charts at run time

Andrew XJ

Board Regular
Joined
Feb 21, 2002
Messages
77
One of projects is to Copy one existing Charts and paste in another place in the same sheet of the source Charts. But i need to change the DataSource and SeriesCollection. I use ChartObjects(1) and to ChartObjects(2) to refer to the object source since they are the first two charts in the sheet. But when i Msgbox ChartObjects(1).Name, it is not the name as shown in the title when i click Chart Window. Why ?
And the data source is not changed even my codes have done that. ??? What are the possible problems when generating Charts.
Note: The charts are not Chart sheet. They are ChartObjects in a worksheet.

The data source is in another worksheet in the same workbook. When contents in data source sheet expands, the more charts will be generated by running a Macro.


regards
Andrew XJ
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
The following are parts of my code. Could you help me to find the problem?

ActiveSheet.ChartObjects(1).Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy

ActiveWindow.Visible = False
Windows(monthlySum).Activate
Range("A" & (10 * loopP - 5)).Select
ActiveSheet.Paste

ActiveSheet.ChartObjects(loopP).Activate
ActiveChart.SeriesCollection(1).XValues = "='Moving Average'!R" & (loopP * 6 - 1) & "C2:R" & (loopP * 6 - 1) & "C9"
ActiveChart.SeriesCollection(1).Values = "='Moving Average'!R" & (loopP * 6) & "C2:R" & (loopP * 6) & "C9"
ActiveChart.SeriesCollection(1).Name = "='Moving Average'!R" & (loopP * 6) & "C1"
ActiveChart.SeriesCollection(2).XValues = "='Moving Average'!R" & (loopP * 6 - 1) & "C2:R" & (loopP * 6 - 1) & "C9"
ActiveChart.SeriesCollection(2).Values = "='Moving Average'!R" & (loopP * 6 + 1) & "C2:R" & (loopP * 6 + 1) & "C9"
ActiveChart.SeriesCollection(2).Name = "='Moving Average'!R" & (loopP * 6 + 1) & "C1"
 
Upvote 0
help...could anyone help me?
The Recorded Macro can work, how come i change the constant cells to variables and then can not work???
 
Upvote 0

Forum statistics

Threads
1,213,507
Messages
6,114,029
Members
448,543
Latest member
MartinLarkin

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