Excel Macro for Charts

W

whitethomas12

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 Where:=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
 
D

Dave D-C

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top