Sub topic 7
Building a line chart
A line chart plots values as points joined by straight segments, so the eye follows change from left to right. This chapter covers how Excel builds one, how it decides between a text axis and a date axis, how it treats blank cells, and the mistakes that produce a wrong-looking chart.
It assumes you can already select a range and insert a chart. It also assumes you know what series and categories are, from the earlier chapters on layout and Select Data.
When a line chart fits
Use a line chart when the categories have a natural order, usually time, and the question is about trend, rhythm, or turning points. The slope between two points carries the message. A column chart shows how big each value is. A line chart shows how the values move.
Lines suit many data points. A column chart with 60 monthly bars becomes cluttered, while a 60-point line stays readable. Lines suit several series too, because crossings and gaps between lines are easy to see.
Avoid lines when the categories have no order, such as regions or products. The segment between "North" and "South" implies a progression that does not exist. Use columns or bars there.
Preparing the data
Put the ordered category (dates, in this example) in the first column and one series per following column. Give every series column a header.
Month Web Store
2026-01-01 320 210
2026-02-01 345 198
2026-03-01 390 220
2026-04-01 410 205
2026-05-01 460 230
2026-06-01 455 240
2026-07-01 500 235
2026-08-01 520 250
2026-09-01 495 245
2026-10-01 540 260
2026-11-01 580 275
2026-12-01 640 310Paste this into A1:C13. Excel converts the first column to real dates. Format that column as mmm yy if you want short labels. A real date is a number underneath, and that matters for the axis type, described below.
Inserting the chart
- Select A1:C13, including the headers.
- Go to Insert, then in the Charts group open Insert Line or Area Chart.
- Choose Line with Markers.
Excel creates two series, Web and Store, with the dates as categories along the horizontal axis. If the chart looks wrong, open Chart Design > Select Data and check which entries appear under Legend Entries (Series) and which under Horizontal (Category) Axis Labels.
The line subtypes
| Subtype | What it draws | Typical use |
|---|---|---|
| Line | Segments only | Many points, where markers add noise |
| Line with Markers | Segments plus a dot at each value | Few points, or when exact positions matter |
| Stacked Line | Each series added onto the one below | Rarely correct, see the warning below |
| 100% Stacked Line | Cumulative percentage shares | Rarely useful |
Text axis or date axis
When the category column holds real dates, Excel can use a date axis. A date axis places points by calendar position. A text axis places each point at an equal interval, whatever the label says.
The difference shows when dates are unevenly spaced. Suppose you have readings on Jan 1, Jan 2, and Mar 1. A text axis spaces the three points equally, which distorts the trend. A date axis puts the third point about two months after the second, so the slope is honest.
To control this:
- Right-click the horizontal axis and choose Format Axis.
- Under Axis Options, find Axis Type.
- Choose Automatically select based on data, Text axis, or Date axis.
- With a date axis, set Base to Days, Months, or Years. Set Major units for the label spacing, for example every 3 months.
Use a text axis on purpose when you want one label per row, for example fiscal periods called "Q1 FY26" that are text anyway.
Blank cells and missing data
Real data has holes. Suppose Store has no value for May. Excel can treat the empty cell in three ways:
| Setting | Result |
|---|---|
| Gaps | The line breaks at the missing point |
| Zero | The line drops to 0, which is almost always misleading |
| Connect data points with line | The line bridges the hole |
Change it in Select Data > Hidden and Empty Cells. The default is Gaps.
Two details trip people up:
- A cell that holds a formula returning
""is not empty. Excel reads it as text and plots it as zero. To skip a point from a formula, returnNA(). Excel then leaves the point out and connects across it, with the#N/Ashowing in the cell. - The Hidden and Empty Cells dialog also has a Show data in hidden rows and columns checkbox. If you hide rows to tidy the sheet, the chart drops those points unless you tick it.
Making the lines readable
A few changes improve most line charts:
- Don't force zero. Unlike columns, a line chart doesn't encode value by length, so the vertical axis may start above zero. Set Minimum under Format Axis when the lines sit in a narrow band. Mention the truncated scale in the title or axis label if the chart is shared.
- Label lines directly. With two to four series, delete the legend and add a data label on the last point of each series, showing the series name. The reader no longer has to match colors to a key.
- Limit series. Past about five lines the chart turns into a tangle. Split it into small charts, or highlight one series and gray out the rest.
- Use smoothing sparingly. In Format Data Series > Fill & Line > Line, Smoothed line curves the segments. The curve invents values between your points and can overshoot. Leave it off for measured data.
- Vary more than color. Use a different marker shape or dash style on each series, so the chart survives grayscale printing.
Common errors
- Years plotted as a series. If the first column holds plain numbers such as 2023, 2024, 2025 with a header, Excel may treat that column as a data series and draw a line climbing through the years. Fix it in Select Data: remove the Year series, then use Edit under Horizontal (Category) Axis Labels to point at the year cells. Storing years as text, or leaving the A1 header cell blank, also avoids the problem.
- Dates showing as numbers. The cells were pasted as text or formatted as General. Convert them to real dates.
- Rows and columns swapped. When the data has more columns than rows, Excel may choose the orientation you did not intend. Use Chart Design > Switch Row/Column.
- Uneven spacing on a text axis. See the section on axis types above.
Creating the same chart with VBA
The chart above takes a few lines of VBA. The key differences from a column chart are the chart type constant and the blank-cell setting.
Sub CreateLineChart()
Dim co As ChartObject
Set co = ActiveSheet.ChartObjects.Add(Left:=100, Top:=50, Width:=450, Height:=260)
With co.Chart
.SetSourceData Source:=ActiveSheet.Range("A1:C13")
.ChartType = xlLineMarkers
.HasTitle = True
.ChartTitle.Text = "Monthly Visits by Channel"
.DisplayBlanksAs = xlNotPlotted
End With
End SubxlLineMarkers is Line with Markers, and xlLine is the plain line. DisplayBlanksAs accepts xlNotPlotted (gaps), xlZero, and xlInterpolated (connect points).
Exercise
A sheet has sensor readings in column A as dates (Jan 1, Jan 2, Mar 1) and values in column B. You draw a line chart, and the jump between Jan 2 and Mar 1 looks as short as the jump between Jan 1 and Jan 2. What is wrong, and how do you fix it?
Show answer
Excel is using a text axis, which spaces every category equally. Right-click the horizontal axis, choose Format Axis, and set Axis Type to Date axis, with Base set to Days. The Mar 1 point then sits about two months to the right of Jan 2, and the slope reflects the real time gap.
Exercise
Column C has a formula that returns "" when a store was closed. The Store line plunges to zero on those months. Why, and what should the formula return so the chart leaves out the point?
Show answer
A formula result of "" is text, not an empty cell, and Excel plots text as zero. Return NA() instead. Excel skips #N/A points and, with the default settings, connects the line across them.