View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Lazzzx Lazzzx is offline
external usenet poster
 
Posts: 24
Default Excel Macro Help for Charts

Hi,
Use R1C1 notation instead of A1 notation.
Your line will then look like this:
ActiveChart.SeriesCollection(1).XValues =
"=(Sheet4!R8C1,Sheet4!R15C1,Sheet4!R23C1)"

R8C1 refers to cell A8 - rows and columns are reversed
The next lines in your code need to be modified too.
rgds,
Lazzzx

skrev i meddelelsen
...
I am getting an error message when trying to have a macro create a
chart. The following is my error message:

Run-Time Error '1004'
Unbale to set the xValue property of the Seris 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 my cells is sheet4 have valid data. I am not sure what I am
doing wrong. The should be created in sheet5