How to display using a Spin Button different series in a chart

gwandalf

New Member
Joined
Feb 16, 2011
Messages
30
Hi! I would like to know how to display using a Spin Button different series in a chart
In the code that there is below this lines there are four series. I plot all of them together but I would like to keep the first one as it is, and be able to choose between the other series as it was one with the Spin Button. Any suggestion? Because I am a bit lost. Thanks in advance

THE CODE

Sub Fer()

Dim XA(1 To 4) As String
Dim XB(1 To 4) As String
Dim XC(1 To 4) As String
Dim i As Long

For i = 1 To 4
XA(i) = "='Sheet1'!R" & i + 1 & "C" & 1 & ""
XB(i) = "='Sheet1'!R" & i + 1 & "C" & 2 & ""
XC(i) = "='Sheet1'!R" & i + 1 & "C" & 3 & ""
Next i

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = "=""Serie 1"""
ActiveChart.SeriesCollection(1).XValues = "='Sheet1'!$A$2:$A$5"
ActiveChart.SeriesCollection(1).Values = "='Sheet1'!$B$2:$B$5"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Name = "=""Speed1"""
ActiveChart.SeriesCollection(2).XValues = XA(1)
ActiveChart.SeriesCollection(2).Values = XB(1)
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Name = "=""Speed2"""
ActiveChart.SeriesCollection(3).XValues = XA(2)
ActiveChart.SeriesCollection(3).Values = XB(2)
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(4).Name = "=""Speed3"""
ActiveChart.SeriesCollection(4).XValues = XA(3)
ActiveChart.SeriesCollection(4).Values = XB(3)

End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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