ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Macro for Charts (https://www.excelbanter.com/excel-programming/404409-excel-macro-charts.html)

[email protected]

Excel Macro for Charts
 
I am trying to create a Macro to create some charts and I am receiving
and error:

Run Time Error '1004'
Unable to set the XValues property of the Series class

The following is my code

Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet5"
ActiveChart.SetSourceData
Source:=Sheets("Sheet4").Range("A3:A23,C3:C23"), _
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=(Sheet4!A8,A15,A23)"
ActiveChart.SeriesCollection(1).Values = _
"=(Sheet4!C9,C16,C24)"
ActiveChart.SeriesCollection(1).Name = "=Sheet4!A2"

All of the referenced cells have data in worksheet. The Macro is ran
from sheet5

Thank you for all of your help

Dave D-C[_3_]

Excel Macro for Charts
 
I think you need
Sheet4!A8,Sheet4!A15,Sheet4!A23
instead of
Sheet4!A8,A15,A23
Dave D-C

wrote:
I am trying to create a Macro to create some charts and I am receiving
and error:

Run Time Error '1004'
Unable to set the XValues property of the Series class

The following is my code

Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet5"
ActiveChart.SetSourceData
Source:=Sheets("Sheet4").Range("A3:A23,C3:C23") , _
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=(Sheet4!A8,A15,A23)"
ActiveChart.SeriesCollection(1).Values = _
"=(Sheet4!C9,C16,C24)"
ActiveChart.SeriesCollection(1).Name = "=Sheet4!A2"

All of the referenced cells have data in worksheet. The Macro is ran
from sheet5

Thank you for all of your help




All times are GMT +1. The time now is 05:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com