Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding chart series with macro

Status
Not open for further replies.

pangerankodok

Programmer
Joined
Feb 20, 2003
Messages
5
Location
ID
Hi all,
I had spreadsheet contain chart.
I want user to be able to paste new data, run the macro, and the new data will be appended into existing chart as new series

I used this code (from macro recorder) and it works.

<code>
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).XValues = &quot;R11C2:R19C2&quot;
ActiveChart.SeriesCollection(2).Values = &quot;R12C3:R19C3&quot;
</code>

The problem is how do I change
XValues = &quot;R11C2:R19C2&quot; and Values = &quot;R12C3:R19C3&quot; dynamically, based on user selection?


Thanks, appreciate all your help..

Iman
 
hello

i would suggest getting the user to select a range, and naming this range. you could then use code something like this to add a new series. the new series should have the same scale as the other series.



Charts(&quot;Plot&quot;).Select 'select the plot you want to change

ActiveChart.SeriesCollection.Add Source:=Sheets(&quot;New_Data&quot;).Range(&quot;NamedRange&quot;)
' add new series from sheet using a named range
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top