P
Paal
Hi, I have the following code which generate a chart with three series. I'm
struggling with solving how I can set the color of the different series. So
any suggestion.
Sub addchart()
With ActiveSheet
Set objChart = .ChartObjects.Add(Left:=1, Width:=720, Top:=1,
Height:=425)
objChart.Chart.ChartType = xlXYScatterSmoothNoMarkers
PT001 = FinnSlutt("M")
Xrange = "=Data!R12C13:R" & PT001 & "C13"
Yrange = "=Data!R12C14:R" & PT001 & "C14"
Result = NySerie(objChart, Xrange, Yrange, "=Data!R11C14", 1)
PT002 = FinnSlutt("R")
Xrange = "=Data!R12C18:R" & PT002 & "C18"
Yrange = "=Data!R12C19:R" & PT002 & "C19"
Result = NySerie(objChart, Xrange, Yrange, "=Data!R11C19", 2)
If (Worksheets("Data").Range("AB12").Value <> "") Then
TT001 = FinnSlutt("W")
Xrange = "=Data!R12C23:R" & TT001 & "C23"
Yrange = "=Data!R12C24:R" & TT001 & "C24"
Result = NySerie(objChart, Xrange, Yrange, "=Data!R11C24", 3)
End If
With objChart.Chart
.PlotArea.Interior.ColorIndex = xlNone
.Refresh
.Axes.MinimumScale = 0
.ax .MaximumScale = 370
End With
end sub
Function NySerie(objChart, Xvalues, Yvalues, Name, x)
objChart.Chart.SeriesCollection.NewSeries
objChart.Chart.SeriesCollection(x).Xvalues = Xvalues
objChart.Chart.SeriesCollection(x).Values = Yvalues
objChart.Chart.SeriesCollection(x).Name = Name
End Function
I have tried with this but get only error.
objChart.Chart.SeriesCollection(1).Interior.ColorIndex = 5
Thanks
Paal
struggling with solving how I can set the color of the different series. So
any suggestion.
Sub addchart()
With ActiveSheet
Set objChart = .ChartObjects.Add(Left:=1, Width:=720, Top:=1,
Height:=425)
objChart.Chart.ChartType = xlXYScatterSmoothNoMarkers
PT001 = FinnSlutt("M")
Xrange = "=Data!R12C13:R" & PT001 & "C13"
Yrange = "=Data!R12C14:R" & PT001 & "C14"
Result = NySerie(objChart, Xrange, Yrange, "=Data!R11C14", 1)
PT002 = FinnSlutt("R")
Xrange = "=Data!R12C18:R" & PT002 & "C18"
Yrange = "=Data!R12C19:R" & PT002 & "C19"
Result = NySerie(objChart, Xrange, Yrange, "=Data!R11C19", 2)
If (Worksheets("Data").Range("AB12").Value <> "") Then
TT001 = FinnSlutt("W")
Xrange = "=Data!R12C23:R" & TT001 & "C23"
Yrange = "=Data!R12C24:R" & TT001 & "C24"
Result = NySerie(objChart, Xrange, Yrange, "=Data!R11C24", 3)
End If
With objChart.Chart
.PlotArea.Interior.ColorIndex = xlNone
.Refresh
.Axes.MinimumScale = 0
.ax .MaximumScale = 370
End With
end sub
Function NySerie(objChart, Xvalues, Yvalues, Name, x)
objChart.Chart.SeriesCollection.NewSeries
objChart.Chart.SeriesCollection(x).Xvalues = Xvalues
objChart.Chart.SeriesCollection(x).Values = Yvalues
objChart.Chart.SeriesCollection(x).Name = Name
End Function
I have tried with this but get only error.
objChart.Chart.SeriesCollection(1).Interior.ColorIndex = 5
Thanks
Paal