Adding source data and matching series color to chart sheet

Matthew23

New Member
Joined
Oct 16, 2015
Messages
1
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
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top