How to Add a Vertical Line to an Excel Graph
In this article
To add a vertical line to an Excel graph, you add a second data series that contains the X value where the line should sit and the Y values that span the chart's height, then change that series to a line chart type. The quickest reliable method is to create a two-point series (the X value twice, once at the bottom and once at the top of the Y axis) and add it to the chart as a new series. This works in Excel for Microsoft 365, Excel 2021, 2019, and 2016 on Windows and Mac. The exact menu labels can differ slightly by version and platform, but the underlying steps are the same.
What You'll Need
- An existing chart in Excel (column, line, scatter, or bar) with a numeric X axis or category axis.
- The X value where you want the vertical line to appear (for example, a date, a month number, or a threshold value).
- A basic understanding of how to select chart data and change chart types.
Step-by-Step
- Identify the X value for your line. Look at your chart's horizontal axis and note the exact value or category where the vertical line should sit. For a date axis, note the date; for a numeric axis, note the number; for a category axis, note the category label (for example, "March"). Write it down so you can enter it exactly.
- Create a small helper table. Somewhere on the same worksheet (or a new sheet), build a two-row table with two columns: one for X and one for Y. In the X column, enter the same X value in both rows. In the Y column, enter the minimum and maximum Y values you want the line to span. For example, if your chart's Y axis runs from 0 to 100, enter 0 in the first row and 100 in the second. If you are not sure of the axis limits, use two values that clearly exceed the visible range (for example, -1000 and 1000) and adjust later.
- Copy the helper table. Select both cells in the X column and both cells in the Y column (a 2x2 range) and press Ctrl+C (Windows) or Command+C (Mac).
- Select the chart. Click once on the chart's plot area or border so the chart is active. Do not click a data point; click the white space inside the chart.
- Paste the data into the chart. Press Ctrl+V (Windows) or Command+V (Mac). Excel adds the helper data as a new series. If the series does not appear, right-click the chart, choose Select Data, click Add, and set the Series X values and Series Y values to your helper cells.
- Change the new series to a line chart type. Right-click the new series (it may appear as columns or points) and choose Change Series Chart Type. In the dialog, set that series to a line chart (usually "Line" or "Line with Markers"). If you do not see the option, right-click the chart, choose Change Chart Type, and use the Combo category to set the helper series to a line while keeping your original series as is.
- Remove markers and adjust the line style. Right-click the new line and choose Format Data Series. Under Marker, set Marker Options to None. Under Line, choose a solid line, set the color (often red or gray), and adjust the width if needed. This makes the line look like a reference marker rather than a data series.
- Check the line position. The line should sit at the X value you entered and span the Y range you specified. If it is off, edit the helper cells and the chart updates automatically. If the line does not reach the top or bottom of the plot area, increase the Y values in the helper table (for example, use -100 and 200 instead of 0 and 100).
- Hide the helper series from the legend (optional). Click the legend and press Delete, or right-click the legend entry for the helper series and choose Delete. Alternatively, keep the legend and rename the series to something meaningful like "Target" or "Event date."
Common Mistakes
- Using a category axis with numeric values. If your X axis is a category axis (text labels), Excel may treat the helper X value as a new category and place the line at the end. To fix this, change the axis type to a date axis or a numeric axis before adding the line, or use a scatter chart instead.
- Forgetting to set the Y values to the axis limits. If the helper Y values are too small, the line will be short. Use values that match or exceed the chart's Y axis minimum and maximum.
- Pasting the data as a new chart instead of a new series. If you paste while a cell is selected rather than the chart, Excel may create a new chart. Always select the chart first.
- Leaving the helper series as columns. The line will look like a thin bar. Change the series chart type to line.
- Not updating the helper table when the chart data changes. The line is tied to the helper cells; if you change the X value, update the helper table too.
Tips
- For a dynamic vertical line that moves with a cell value, put the X value in a cell and reference it in the helper table. Changing the cell moves the line.
- Use a dashed line style for the vertical line to distinguish it from data series.
- If you need multiple vertical lines, create additional helper series (one per line) and add them the same way.
- On a scatter chart, you can add a vertical line by adding a new series with two points: (X, Ymin) and (X, Ymax), then formatting as a line.
- To avoid clutter, hide the helper series from the legend and set its marker to none.
Troubleshooting
If the vertical line does not appear after pasting, check that the helper table has exactly two rows and that both X values are identical. If the line appears but is in the wrong place, verify the X value matches the axis scale; for date axes, ensure the date is entered in a format Excel recognizes. If the line is too short, increase the Y values in the helper table. If the line is not straight (for example, it slopes), you likely have more than two data points or the X values differ; correct the helper table. If you cannot change the series chart type, ensure you are using a combo chart or that the chart type supports multiple series types (scatter and pie charts do not). If the line disappears when you update the chart data, re-check that the helper series is still included in the chart's data range.
Frequently Asked Questions
Can I add a vertical line to any chart type?
Yes, most chart types that support multiple series (column, line, scatter, bar) can include a vertical line using a helper series. Pie and doughnut charts do not support this method.
How do I make the vertical line span the entire chart height?
Set the Y values in the helper table to the minimum and maximum of your chart's Y axis. If you do not know the exact limits, use values well beyond the visible range and adjust.
Why does my vertical line appear as a column?
The helper series is still set to a column chart type. Right-click the series, choose Change Series Chart Type, and select a line type.
Can I add a vertical line without a helper table?
No, Excel does not have a built-in vertical line feature. You need a helper series with at least two points.
Does this work in Excel for Mac?
Yes, the steps are the same, though menu labels may differ slightly. Use Command instead of Ctrl for copy and paste.
How do I remove the vertical line later?
Select the line and press Delete, or right-click the series and choose Delete. You can also remove the helper series via Select Data.