Home » excel » excel vba – how to show markers for one series and not for another

excel vba – how to show markers for one series and not for another

Posted by: admin April 23, 2020 Leave a comment

Questions:

A part of my current assignment is to, once all data has been calculated successfully (it has), is to plot a scatter showing altitude against time.

This plot requires two series. One for the trajectory start to finish and another to show the apogee.

I have managed to get the chart to show this by defining the scatter as xlXYScatterSmooth. I would prefer the full length series to have no markers though.

How do I do this?

Dim Chart1 As Chart
Dim xaxis As Range
Dim yaxis As Range
Dim MAXyaxis As Range
Dim Series As Series
Dim SeriesMAX As Series

Set yaxis = DisplayCorrectedAlt
Set xaxis = Range(Cells(1, 1), Cells(RowCount, 1))
Set MAXyaxis = Cells(1, 9)
Set MAXxaxis = Cells(1, 10)

Set Chart1 = Charts.Add
    With Chart1
        .ChartType = xlXYScatterSmooth
    End With

Set Series = Chart1.SeriesCollection.NewSeries
    With Series
        .Values = yaxis
        .XValues = xaxis
    End With

Set SeriesMAX = Chart1.SeriesCollection.NewSeries
    With SeriesMAX
        .Values = MAXyaxis
        .XValues = MAXxaxis

    End With
How to&Answers:

You can use .MarkerStyle = xlMarkerStyleNone against the DataSeries object.

Place it inside the With block of the desired series, like this:

With SeriesMAX
    .Values = MAXyaxis
    .XValues = MAXxaxis
    .MarkerStyle = xlMarkerStyleNone
End With