Add Vertical Lines To Excel Charts Like A Pro! [Guide]
There are a few creative ways to add a vertical line to your chart bouncing around the internet. If you have landed on this article, I assume you are looking for an automated solution so you don’t have to manually drag the line(s) you drew on your spreadsheet every month.
Well, you have come to the right place!
In this article, you will learn the best way to add a dynamic vertical line to your bar or line chart. This technique is fairly easy to implement but took a lot of creative thinking to develop (I definitely did not create this technique but it’s been well known among Excel chartists for decades).
In this article, we’ll cover 3 topics:
- Embedding Vertical Line Shapes Into A Chart (Simple Method)
- Creating A Dynamic Vertical Line In Your Chart (Advanced Method)
- Adding Text Labels Above Your Vertical Line
I do have an example Excel file available to download near the end of this article in case you get stuck on a particular step.
Embedding A Vertical Line Shape Into A Chart
This first method is the quick and dirty way to get a vertical line into your chart. I only recommend this method if this is a single-use chart and you will not have to be moving the vertical line around in the future. You’ll learn a more dynamic methodology in the next section of this article.
Create Your Line
First, you will need to draw a line shape on your spreadsheet. You can do this by navigating to the Insert tab and opening the Shapes menu button.
Select the line button and your cursor should change to be in Draw Mode.
Hold down your SHIFT key on the keyboard and click where you want your line to begin and drag downward to add length to your line.
If your line looks a little slanted, you can ensure the width of the line = 0 to force it to be zero (in the Shape Format tab). If you want to change the length of your line, you can hold the SHIFT key down while you adjust to ensure it remains perfectly vertical.
Format Your Line
You’ll likely want to modify the formatting of your line from the default look. There are many formatting options available to you in the Shape Format tab. This contextual Ribbon tab appears when you have the line shape selected.
For chart lines, I typically modify the following line properties:
- Line Weight: 2.25 – 3.00 pts
- Dashes: Rounded Dots
- Shape Outline Color: Medium/Light Grey
Embed Your Line Into The Chart
Now that you have your vertical line looking the way your want, it’s time to add it to your chart.
Many people will just reposition the line on top of the chart and call it a day. This is really poor practice since the line will not reposition if you happen to move or resize your chart. You will also have to remember to select both the chart and the line objects before copying, to capture the entire chart graphic.
You really should embed the vertical line inside your chart so it becomes part of the chart object. This can be done by:
- Copy the vertical line shape (CTRL + C)
- Select the Chart Object
- Paste (Ctrl + V)
Reposition Your Line
After you paste the line into your selected Chart object, you should see the line appear inside the chart. You can then proceed to reposition the line with your mouse. Unfortunately, you cannot use the arrow keys on your keyboard to reposition a shape or textbox embedded in a chart object.
For vertical lines, I recommend making the line start on the X-axis and end at the very top of the Plot Area. The Plot Area is the box that gets outlined in your Chart when you click on the white space between your bars.
To update the position of the vertical line in the future, you just need to remember to move the line inside the chart. We’ll discuss a more advanced technique in the next section which will allow you to automate moving the line across your chart.
Creating A Dynamic Vertical Line In Your Chart
If you are looking for a more automated/long-term solution for incorporating a vertical line into your chart, this is going to be the solution for you.
The technique we’ll be using incorporates a single-pointed Scatter Plot (x,y) in combination with your current chart. The single point charted on the Scatter Plot will control the location of the vertical line.
We will then turn on vertical Error Bars (margin of error indicators), repurposing them to visually display a vertical line on the chart.
Now if that explanation went way over your head, don’t worry! I will walk you through each step and show you it’s really not that difficult to set this up.
Chart Starting Point
I’m going to assume you already have your chart created and you are looking to add the vertical line to the pre-existing chart. With this assumption in mind, I’ll forgo walking you through how to create a chart in Excel.
For this example, we’ll use the below chart to start with and we will work to insert a vertical line to separate the Actual months from the Forecast months.
Create A Combo Chart
The vertical line will need to be plotted using a Scatter Plot chart. Chances are you are working with either a Bar Chart or a Line Chart, so we will need to turn your chart into a Combo Chart. Combo Charts can accommodate different charting types within a single Chart object.
Before you can set up a Combo Chart, your chart will need to have an additional chart series that we can plot to. You can add an additional row of temporary data to your chart data and ensure a new chart series is connected to it (through the Select Chart Data dialog box).
Once your chart has the additional chart series added, select the entire chart and navigate to the Chart Design tab in the Excel Ribbon.
Select the Change Chart Type button to launch the Change Chart Type dialog box. Once the dialog box appears, click on the Combo menu item in the left-side pane.
Look for the series you set up to chart the vertical line and ensure its Chart Type designation is changed to Scatter. Also, make sure the Secondary Axis checkbox remains unchecked.
Once you have made your changes, you can click the OK button to finish converting your chart to a Combo Chart.
Create the Scatter Plot Series
Once you have added Scatter Plot capabilities to your chart, you can then begin to set up your x and y coordinates for your vertical line.
Right-click on your chart and go to Select Data.
Ensure the Series Name you designated as a Scatter Plot series is selected and click the Edit button.
You can then begin to link your X and Y coordinates for your series. In this case, you will want the Y value = 0 and your X value to be halfway between the two bars you wish the vertical line to reside. In this example, since our first forecast month is April, the X value will equal 3.5.
You can hardcode your Y value to zero if you’d like (no cell reference) or link it up to a cell reference to visually show the full coordinates in the spreadsheet.
Adding Vertical Error Bars
So how do we turn a single dot on a Scatter Plot into a vertical bar with no dot? Now is time for the creative part!
What we will be adding to the plotted dot is an Error Bar. What is an Error Bar you might be thinking? It is used in statistics to indicate the margin of error for a given value. This allows someone to chart a value but show the audience that the value might be within a range of numbers that are either greater or less than that value.
We can use this margin indicator line to our advantage and setup up the spreadsheet to allow us to draw a vertical line right on the chart. To add an Error Bar you will need to follow the below steps.
- Select the Scatter Plot series
- Navigate to the Chart Design Ribbon tab
- Open the Add Chart Element menu
- Open the Error Bars menu
- Select More Error Bars Options…
The Format Error Bars Pane should appear on the right-hand side of your Excel application window.
Open the Error Bar Options drop-down menu and ensure the Y Error Bars for your Series is selected.
Change the Direction = Plus and End Style = No Cap.
For the Error Amount, choose Custom and click the Specify Value button. This will open a dialog box where you will need to designate a Positive and Negative value for your Error margin. Since our plotline is already at zero, we only want our margin to be positive. For this reason, you can set the Negative value to 0.
The positive value will determine the length of your line. You will typically want this to be equal to or greater than the largest value in your bar/line chart.
For an even more dynamic solution, I recommend setting up a cell that reads the values from your chart and determines the maximum value. In this example, the cell used has the formula:
If you want to ensure your line ends a little bit higher than your max value, you can add a percentage increase to your formula. Typically adding 5% does the trick for me. This will change your formula to look something like this:
=MAX(B20:M20) * 105%
After you have set up your Custom Error Bar, you should see the line plotted on your chart.
Formatting The Vertical Line
Once your vertical line is created, the last step will be to format your line to your desired look. Here are the format settings I will typically use:
- Line Weight: 1.5 pts
- Dashes: Rounded Dots
- Shape Outline Color: Medium/Light Grey
- Marker Fill Color: None
- Marker Border Color: None
After some further format changes to the chart itself, you can have a very professional-looking chart with a vertical line plot directly inside it.
Automating The Vertical Line’s Movement
You may choose to manually update the vertical lines’ X Value every time, but you may also be able to utilize a formula to handle the movement for you.
Let’s look at the article example. The vertical line represents the separation of Actual vs. Forecast Sales results.
Looking at the data table, we can incorporate a simple COUNTIFS function to count how many months are designated as “Actuals”. This way, as the year progresses, the vertical line in the chart will move along as more and more months become “Actuals”.
Depending on your situation, you may be able to come up with a similar sort of formula to automate your vertical line movement as time progresses.
Adding Text Labels Above Your Vertical Line
Now let’s say you want to add a label to your vertical line to give your audience clarity on what it is defining. We can tweak the setup of the vertical line to incorporate the use of a data label.
In order to position a data label at the top of the vertical line, we’ll need to move our plotted dot to the very top of the line.
To do this, you simply need to turn your Max Bound value negative and ensure your Y value has a formula equating to a positive version of your Max Bound value (just multiply by -1).
This will move your plotted dot up to the top and carry your line length down southbound (negative) to end at zero.
After you’ve re-jiggered your vertical line setup, you can then proceed to add a data label. Simply select your plotted dot and right-click on it. Then open the Add Data Labels menu and click Add Data Labels.
You should then see a data label appear next to your vertical line.
Next, you’ll likely want to reposition your data label to be directly over your vertical line. To do this, select and right-click on your data label. Click the Format Data Point menu option and the Format Data Label pane should open up.
In the Label Position section of the Label Options, select Above.
Finally, you’ll want to customize the text that is stored in the label. After selecting the Data Label, you can write a text formula (similar to the screenshot above) or you can link the Data Label to a spreadsheet cell with your desired text value.
The final result should look something like this:
Download Examples In Excel
If you would like to instantly download an Excel file I put together with exact chart examples used in this article along with a few other examples, feel free to click the below download button. No strings attached 🙂
I Hope This Helped!
Hopefully, I was able to explain how you can add a vertical line to your Excel Charts. If you have any questions about this technique or suggestions on how to improve it, please let me know in the comments section below.
Learn my best Excel chart design hacks. These will turn your ugly charts into professionally crafted graphics, leaving your boss speechless!!!
How To Create Excel Progress Bar Charts (Professional-Looking!)
Creating A Progress Bar In Excel Progress Bars are simple graphics that can be quite visually powerful by instantly providing...
Hiding A To-Date Column When Reporting Month or Quarter End Results
The "To-Date" Column I was first introduced to this concept a few years ago when I first started working in...
Chris is a finance professional and Excel MVP recognized by Microsoft since 2016. With his expertise, he founded TheSpreadsheetGuru blog to help fellow Excel users, where he shares his vast creative solutions & expertise. In addition, he has developed over 7 widely-used Excel Add-ins that have been embraced by individuals and companies worldwide.