In general, despite the output of the macro recorder, VBA works more
reliably if you don't specify the ChartType until after the chart is
populated with data. Also, you have better control if you dispense with
SetSourceData, and instead delete any series in the newly created chart,
then use .NewSeries and .Values and .XValues to create and populate each
series.
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -
http://PeltierTech.com
_______
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The following code works fine in 2007. In 2003, I get error "1004 -
> Unable to set the XValue property of the Series class" on the line
> with the asterisk (*). If I move the line " chartpoint.ChartType =
> xlLineMarkers" to after the line with the asterisk, it works fine
> until it gets to the next line. I have been rearranging lines, but
> have not found any arrangement that works with 2003. Any ideas?
>
>
> newchart.Chart.SetSourceData Source:=.Range(.Cells(irow + 1,
> 1), .Cells(irow + 4, 61)) _
> , PlotBy:=xlRows
> Set chartpoint = newchart.Chart
>
> chartpoint.HasLegend = False
> chartpoint.HasDataTable = True
> chartpoint.DataTable.ShowLegendKey = True
> chartpoint.ChartType = xlLineMarkers
> chartpoint.HasTitle = True
> chartpoint.ChartTitle.Text = tpms(itask, itpm)
> chartpoint.Axes(xlCategory, xlPrimary).HasTitle = False
> chartpoint.Axes(xlValue, xlPrimary).HasTitle = True
> chartpoint.Axes(xlValue).AxisTitle.Text = units(itask, itpm)
>
> * chartpoint.SeriesCollection(1).XValues = .Range("b6:bi6")
> chartpoint.SeriesCollection(1).Format.Line.Visible = False
> chartpoint.SeriesCollection(1).Border.LineStyle = xlNone
> chartpoint.SeriesCollection(1).MarkerBackgroundColorIndex = 3
> chartpoint.SeriesCollection(1).MarkerForegroundColorIndex = 3
> chartpoint.SeriesCollection(1).MarkerStyle = xlDiamond
> chartpoint.SeriesCollection(1).Smooth = False
> chartpoint.SeriesCollection(1).MarkerSize = 5
> chartpoint.SeriesCollection(1).Shadow = False
>
> chartpoint.SeriesCollection(2).XValues = .Range("b6:bi6")
> chartpoint.SeriesCollection(2).Format.Line.Visible = False
> chartpoint.SeriesCollection(2).Border.LineStyle = xlNone
> chartpoint.SeriesCollection(2).MarkerBackgroundColorIndex = 5
> chartpoint.SeriesCollection(2).MarkerForegroundColorIndex = 5
> chartpoint.SeriesCollection(2).MarkerStyle = xlSquare
> chartpoint.SeriesCollection(2).Smooth = False
> chartpoint.SeriesCollection(2).MarkerSize = 5
> chartpoint.SeriesCollection(2).Shadow = False
>
> chartpoint.SeriesCollection(3).XValues = .Range("b6:bi6")
> chartpoint.SeriesCollection(3).Border.ColorIndex = 4
> chartpoint.SeriesCollection(3).Border.Weight = xlThick
> chartpoint.SeriesCollection(3).Border.LineStyle = xlContinuous
> chartpoint.SeriesCollection(3).MarkerStyle = xlNone
> chartpoint.SeriesCollection(3).Smooth = False
> chartpoint.SeriesCollection(3).Shadow = False
>
> chartpoint.SeriesCollection(4).XValues = .Range("b6:bi6")
> chartpoint.SeriesCollection(4).Border.ColorIndex = 6
> chartpoint.SeriesCollection(4).Border.Weight = xlThick
> chartpoint.SeriesCollection(4).Border.LineStyle = xlContinuous
> chartpoint.SeriesCollection(4).MarkerStyle = xlNone
> chartpoint.SeriesCollection(4).Smooth = False
> chartpoint.SeriesCollection(4).MarkerSize = 5
> chartpoint.SeriesCollection(4).Shadow = False
>
> chartpoint.PlotArea.Interior.Color = vbWhite
>
> chartpoint.PlotArea.Border.ColorIndex = 2
> chartpoint.PlotArea.Border.Weight = xlThin
> chartpoint.PlotArea.Border.LineStyle = xlContinuous
>