View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
premuratus premuratus is offline
external usenet poster
 
Posts: 4
Default chart with macro

i record a macro which plot a chart getting its data from sheet1's columns.
it's works inwhich created Excel workbook but when i try to run in different
Excel workbook which has different name, macro returns "unable to set Xvalues
property of series class" eror. I think this is because of the column
adressing for "chart series data". How can i create a macro which gets its
data from active workbook's active sheet columns?

Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SetSourceData
Source:=ThisWorkbook.Sheets("Sheet1").Range("H100" )
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
'code fail here...
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!C5"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!C4"