I have an array of original source data (DataRange) that is used to generate my chart but I also have a similar set of data that i want to superimpose over the top on the chart in a different line style but same colour (DataRange2).
The reason i want to do this is because DataRange2 is a slightly smaller set of values based on a restriction imposed on the original data. However I still want the original data plotted as a dotted line underneath and extending past the new data.
So far I have:
....................................................
Sub CreateMyChart()
Dim MyChart As Chart
Dim DataRange As Range
Dim DataRange2 As Range
Set DataRange = ActiveSheet.Range("I9:W20")
Set DataRange2 = ActiveSheet.Range("AC10:AP20")
Set MyChart = Charts.Add
MyChart.SetSourceData Source:=DataRange
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.ChartStyle = 2
ActiveChart.SeriesCollection.Add Source:=DataRange2
With ActiveChart.Axes(xlCategory)
.HasTitle = True
.AxisTitle.Text = "Angle of Corrugation"
.HasMajorGridlines = True
End With
With ActiveChart.Axes(xlValue)
.HasTitle = True
.AxisTitle.Text = "Moment Capacity (Mp) in kNm"
.HasMajorGridlines = True
.DisplayUnit = xlMillions
.HasDisplayUnitLabel = False
.MinimumScale = 30000000#
.MaximumScale = 700000000#
End With
With ActiveChart.SeriesCollection(1)
.Name = "Control"
.MarkerStyle = xlMarkerStyleCircle
.MarkerForegroundColor = 0
.MarkerBackgroundColor = 0
.Format.Line.Visible = msoFalse
End With
'Changing series line weights and naming legend
For i = 2 To 11
With ActiveChart.SeriesCollection(i)
.Format.Line.Weight = 1#
.Format.Line.DashStyle = msoLineSysDot
End With
Next i
For i = 12 To 22
With ActiveChart.SeriesCollection(i)
.Format.Line.Weight = 1.5
.Format.Line.color = color(i - 11)
End With
Next i
End Sub
..............................
The second bit of data is getting plotted but a few of the series in the second set are not plotting
Also I can't get the colours to line up between the two
The reason i want to do this is because DataRange2 is a slightly smaller set of values based on a restriction imposed on the original data. However I still want the original data plotted as a dotted line underneath and extending past the new data.
So far I have:
....................................................
Sub CreateMyChart()
Dim MyChart As Chart
Dim DataRange As Range
Dim DataRange2 As Range
Set DataRange = ActiveSheet.Range("I9:W20")
Set DataRange2 = ActiveSheet.Range("AC10:AP20")
Set MyChart = Charts.Add
MyChart.SetSourceData Source:=DataRange
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.ChartStyle = 2
ActiveChart.SeriesCollection.Add Source:=DataRange2
With ActiveChart.Axes(xlCategory)
.HasTitle = True
.AxisTitle.Text = "Angle of Corrugation"
.HasMajorGridlines = True
End With
With ActiveChart.Axes(xlValue)
.HasTitle = True
.AxisTitle.Text = "Moment Capacity (Mp) in kNm"
.HasMajorGridlines = True
.DisplayUnit = xlMillions
.HasDisplayUnitLabel = False
.MinimumScale = 30000000#
.MaximumScale = 700000000#
End With
With ActiveChart.SeriesCollection(1)
.Name = "Control"
.MarkerStyle = xlMarkerStyleCircle
.MarkerForegroundColor = 0
.MarkerBackgroundColor = 0
.Format.Line.Visible = msoFalse
End With
'Changing series line weights and naming legend
For i = 2 To 11
With ActiveChart.SeriesCollection(i)
.Format.Line.Weight = 1#
.Format.Line.DashStyle = msoLineSysDot
End With
Next i
For i = 12 To 22
With ActiveChart.SeriesCollection(i)
.Format.Line.Weight = 1.5
.Format.Line.color = color(i - 11)
End With
Next i
End Sub
..............................
The second bit of data is getting plotted but a few of the series in the second set are not plotting
Also I can't get the colours to line up between the two