user2573493
user2573493

Reputation: 11

Chart line drawn at 100%

I have been trying to figure this out for hours. Apologize in advance if the answer is already out there, but I haven't found it.

I have a chart where the Y-Axis is Max at 100%. However, the X-Axis is varible based on the data. The X-Axis, for example can reach +300%.

I would like to draw a verticle line on the chart where the X-Axis is 100%, so it is more obvious to the user where 100% has been exceeded.

Help is appreciated!

Excel VBA skills are generally strong, but weak where chart manipulation is concerned.

Upvotes: 1

Views: 244

Answers (1)

Tim Williams
Tim Williams

Reputation: 166196

Sub AddLine()

Dim cht As Chart, s As Series

    Set cht = ActiveSheet.ChartObjects(1).Chart

    Set s = cht.SeriesCollection.NewSeries
    With s
        .XValues = Array(100, 100)
        .Values = Array(0, 100)
        .Name = "100%"
        .MarkerStyle = -4142
        With .Format.Line
            .Weight = 1
            .ForeColor.RGB = RGB(255, 0, 0)
        End With
    End With

End Sub

Upvotes: 0

Related Questions