7 Ways To Create a Line Graph in Excel

If you want to learn how to create a line graph in Excel, follow along with this effortless Microsoft Excel tutorial.

You commonly use a line graph to track changes over time, showcasing trends, growth, or declines within a continuous dataset. This data visualization is particularly effective for visualizing data that changes regularly, such as monthly sales figures, daily temperatures, or yearly population growth.

Read on as I explain various methods of making a line graph in Excel for different datasets, use cases, and level of expertise.

Using the Default Chart Hotkey

Sample dataset 1

Is the input dataset for the chart already organized like the one shown above? Then follow these steps:

Default column chart
Default column chart

Select the whole dataset and press Alt + F1.

Change Chart Type
Change Chart Type

You’ll see an automatic column chart on the worksheet. Click on that to open the Chart Design tab.

Go to the Chart Design tab and click on the Change Chart Type command.

Choose line chart
Choose line chart

The All Charts tab will open on the Change Chart Type dialog box.

Choose Line from the left side navigation panel.

Create a line graph using a hotkey
Create a line graph using a hotkey

Select the first line chart you see in the dialog box. Click OK to replace the default chart with a line chart.

Using the Quick Analysis Tool

Select dataset open Quick Analysis Tool
Select dataset open Quick Analysis Tool

Highlight the input dataset and press Ctrl + Q to launch the Quick Analysis tool in the bottom right corner of the selected dataset.

More charts in Quick Analysis Tool
More charts in Quick Analysis Tool

Navigate to the Charts tab and click on the More option.

Select basic Line chart
Select basic Line chart

This will open the Insert Chart dialog box.

Navigate to the All Charts tab and click on the Line category in the left-side navigation panel.

Make a line graph in Excel using Quick Analysis tool
Make a line graph in Excel using Quick Analysis tool

Now you can choose from various line graphs, like the ones listed below:

  • Basic Line chart: Connects data points with lines to show trends over categories or time.
  • Stacked Line: Layers the data series lines on top of each other, showing how each contributes to the total value.
  • 100% Stacked Line: Similar to a stacked line, each line represents a percentage of the total, always summing up to 100%.
  • Line with Markers: Adds data point markers (like circles or squares) to a basic line chart for better visualization.
  • Stacked Line with Markers: Combines stacked lines with markers for each data point on the stacked lines.
  • 100% Stacked Line with Markers: Combines 100% stacked lines with markers for each data point on the percentage lines.
  • 3-D Line: Presents a basic line chart with depth, but can be visually cluttered and harder to interpret.

Using the Recommended Charts Command

The Recommended Charts tool is the default location of all Excel data visualization graphs including line charts. Learn below how to use this command effortlessly:

Sample dataset 2

In a line chart, category data are plotted over time. So, organize your dataset according to the example given above.

Recommended charts on ribbon
Recommended charts on ribbon

Select your input dataset and click on the Insert tab on the Excel ribbon.

Insert Chart dialog with a basic Line chart
Insert Chart dialog with a basic Line chart

Click on the Recommended Charts command inside the Charts commands block.

Now, you should see the Insert Charts dialog. There, you can choose the auto-populated line chart item in the left-side navigation tab.

Adding a line chart from Line category
Adding a line chart from Line category

Alternatively, click on the All Charts tab and choose any line chart you want to insert from the Line category menu on the left-side panel.

Click OK on the dialog box to add the line chart to the active worksheet.

A basic Line chart structure
A basic Line chart structure

Excel will insert the basic line graph as shown above.

You might want to customize the chart to present data effectively. Your first task is to add Data Labels for the categories plotted on the vertical axis or Y-axis.

Checkmark Data Labels
Checkmark Data Labels

Click on a category line on the graph and hit the Chart Elements icon. It’s the plus (+) icon in the top right right corner of the chart you’ve added. The icon will only show if you select the chart first.

On the Chart Elements context menu, checkmark the checkbox for Data Labels.

If you’ve selected the category that’s on the top and the Data Labels happen to also show up above the line, keep this as is.

Upper Data Labels position
Upper Data Labels position

However, when the Data Labels show below the category line, hover the cursor over the Data Labels option in the context menu. An arrow will show up. Click on that and choose Above as the position of Data Labels.

Pushing Data Labels to bottom
Pushing Data Labels to bottom

Now, repeat the above steps for the next category, which might be below the first one. For this line, click on the Data Labels expansion menu and choose the Below option.

Editing chart titles
Editing chart titles

The chart title helps the audience to get a context of the data being presented. So, customize it by double-clicking the Chart Title text box at the top of the line chart you’ve just added.

Make a line graph with Excel with customizations
Make a line graph with Excel with customizations

Find the final line graph that I created by following the same instructions given above.

Using the PivotChart Command

When the input dataset of the line chart changes dynamically as you update the workbook, you can use PivotChart.

Also, when your data requires multiple aggregations, like sales by region, then by product, then by time period, and so on, PivotCharts become handy. These charts allow you to aggregate and rearrange data effortlessly.

Moreover, if you need to create interactive reports where users can change the data view dynamically, PivotCharts provides a user-friendly way to interact with the data.

Create PivotChart
Create PivotChart

Navigate to the worksheet dataset you want to include in a PivotChart line graph. Select the data and click on the PivotChart command in the Charts block of the Insert tab.

The Create PivotChart dialog will open. It should automatically select the input data range on the worksheet.

Selecting a custom destination on worksheet
Selecting a custom destination on worksheet

Click on the Existing Worksheet radio button, and identify the destination range using the Location field.

Now, select the OK button on the dialog box to start creating the PivotChart as well as a PivotTable.

PivotChart Fields
PivotChart Fields

You should see the PivotCharts Fields navigation panel on the right side.

PivotChart default column graph
PivotChart default column graph

There, drag and drop the Month item of the data into the Axis (Categories) box at the bottom of the panel.

Now, drag the quantitative values, those you want to plot along the Y-axis into the Values box of the PivotCharts Fields panel.

You’ll see a column chart.

Rearrange items in the PivotTable
Rearrange items in the PivotTable

If the X-axis items aren’t organized in ascending order, you can change their positions in the PivotTable on the right by dragging and dropping one row at a time.

Change Chart Type PivotCharts
Change Chart Type PivotCharts

Once the row orders are corrected, click on the PivotChart and go to the Design tab.

Switch to Line charts
Switch to Line charts

Click on the Change Chart Type command and choose a line chart from the dialog box that follows.

Make a Line Chart in Excel using PivotCharts
Make a Line Chart in Excel using PivotCharts

Excel will change the existing column chart to a line graph instantly.

Creating Mini Linecharts Using Sparklines

For your time series data, you can also go for the Line sparklines in Excel to create line charts within the cell. This method allows you to visualize the trend data over a period of time in a small place or dashboard.

Not to mention, you can integrate sparklines with text paragraphs to illustrate points without breaking the flow of the text. This is useful in analytical reports, executive summaries, and other narrative formats.

Sample dataset 4

For example, you’ve got a dataset as shown above for sales of different products for five consecutive quarters.

Choose Line Sparklines
Choose Line Sparklines

Select the entire dataset except for the column header texts.

Click on the Insert tab and select the Line command inside the Sparklines commands block.

Create Sparklines
Create Sparklines

The Create Sparklines dialog will show up. Click within the Location Range field and select the cell range adjacent to the right side of the target dataset.

Create Line charts with Sparklines
Create Line charts with Sparklines

That’s it! Your sparklines line charts are created inside the selected cell range.

Stock Quote Line Graph With Data Connection

If you wish to create a dynamically updated line chart for stocks, bonds, etc., you can use this method.

Sample dataset 5

Create a Stock column in your worksheet and populate the names of NASDAQ-listed companies you want to monitor for price movements. Refer to the sample dataset screenshot given above.

Stocks
Stocks

Now, select the stock names in the column and click on the Stocks command inside the Data Types block of the Data tab.

Reformatting stock names
Reformatting stock names

Excel will match the company names with Microsoft’s proprietary stock quote API service and reformat the entries appropriately so the API can function.

If you see the information notification or question mark circle for any stock name in the list, that item doesn’t exist in the stock quote API. So, remove those entries to make the list of stocks fully compatible with the stock quote API.

Insert Data icon
Insert Data icon

Now, select all the stocks within the column and click on the tiny Insert Data icon in the top right corner of your selection.

52 week high
52 week high

This will open a context menu from which you can pick any of the following:

  • 52 week high
  • 52 week low
  • Change
  • Change (%)
  • Currency
  • Market cap
  • P/E ratio
  • Previous close
Data collected from stock quote API
Data collected from stock quote API

Find above a dynamic 52-week high stock price monitoring dataset created using the stock quote API.

Create Line graph from stock data
Create a Line graph from stock data

Now, select the whole dataset and click on the Insert Line or Area Chart drop-down menu within the Charts block of the Insert tab.

From the context menu that opens, choose the Line with Markers graph.

Created line graph from Stock Quote
Created line graph from Stock Quote

In the chart you create, the 52-week high price quotes of various stocks in the dataset will be plotted on the Y-axis. In the X-axis, you’ll find the stock names.

The drawback of this method is it’s only available for Excel for the web, Excel for Microsoft 365 for Mac, and Excel for Microsoft 365. In older Excel editions, you won’t find this feature.

Using Excel VBA

You can fully automate the line chart creation and customization in Excel using VBA. You can either create a non-visual script that will simply execute the task it has been programmed for. Alternatively, you can create visual boxes to walk you or any other users throughout the process.

Before taking a deep dive into the script, learn how to create a VBA macro here:

📒 Read More: How To Use The VBA Code You Find Online

Now, you can use this script to create your own macro:

VBA script 1
Sub CreateCustomLineChart()
    Dim XRange As Range
    Dim YRange1 As Range
    Dim YRange2 As Range
    Dim ChartTitle As String
    Dim ChartObject As ChartObject
    Dim Chart As Chart

    ' Step 1: Select X-axis dataset
    On Error Resume Next
    Set XRange = Application.InputBox("Select the X-axis data range:", Type:=8)
    On Error GoTo 0
    If XRange Is Nothing Then Exit Sub

    ' Step 2: Select first Y-axis dataset
    On Error Resume Next
    Set YRange1 = Application.InputBox("Select the first Y-axis data range:", Type:=8)
    On Error GoTo 0
    If YRange1 Is Nothing Then Exit Sub

    ' Step 3: Select second Y-axis dataset
    On Error Resume Next
    Set YRange2 = Application.InputBox("Select the second Y-axis data range:", Type:=8)
    On Error GoTo 0
    If YRange2 Is Nothing Then Exit Sub

    ' Step 4: Enter chart title
    ChartTitle = InputBox("Enter the chart title:")

    ' Create the chart
    Set ChartObject = ActiveSheet.ChartObjects.Add(Left:=100, Width:=375, Top:=75, Height:=225)
    Set Chart = ChartObject.Chart
    Chart.ChartType = xlLineMarkers
    Chart.SetSourceData Source:=Union(XRange, YRange1, YRange2)
    Chart.HasTitle = True
    Chart.ChartTitle.Text = ChartTitle

    ' Add data labels to all series
    Chart.ApplyDataLabels Type:=xlDataLabelsShowValue
    Chart.SeriesCollection(1).DataLabels.Position = xlLabelPositionAbove
    Chart.SeriesCollection(2).DataLabels.Position = xlLabelPositionBelow

    ' Adjust data label font size to prevent overlap
    Chart.SeriesCollection(1).DataLabels.Font.Size = 10
    Chart.SeriesCollection(2).DataLabels.Font.Size = 10
End Sub

The above script will do the following when you run the VBA macro:

Input box for X-axis data
Input box for X-axis data
  • Show an input box so you can choose the dataset for the X-axis.
  • There will be two more input boxes so you can choose two datasets for the Y-axis.
Chart title customization
Chart title customization
  • You’ll also get the option to choose the chart title for your line graph.
Line graph created using Excel VBA
Line graph created using Excel VBA

As soon as you supply the above details accurately, Excel will create the line graph for you.

Conclusions

So far, you’ve learned how to create a line graph in Excel in 7 different ways.

If you’re new to Excel, practice the methods that utilize various Excel user interface commands.

However, if you want to automate the task or would like to give the programmatic approach a spin, try out the VBA-based method too.

If this in-depth Microsoft Excel article helped you to navigate the complicated space of Excel line graphs, you can share your acknowledgment below. If I missed a popular method to make a line graph, add that in your comment.

About the Author

Tamal Das

Tamal Das

I'm a freelance writer at HowToExcel.org. After completing my MS in Science, I joined reputed IT consultancy companies to acquire hands-on knowledge of data analysis and data visualization techniques as a business analyst. Now, I'm a professional freelance content writer for everything Excel and its advanced support tools, like Power Pivot, Power Query, Office Scripts, and Excel VBA. I published many tutorials and how-to articles on Excel for sites like MakeUseOf, AddictiveTips, OnSheets, Technipages, and AppleToolBox. In weekends, I perform in-depth web search to learn the latest tricks and tips of Excel so I can write on these in the weekdays!

Related Posts

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get the Latest Microsoft Excel Tips

Follow Us

Follow us to stay up to date with the latest in Microsoft Excel!

Subscribe for awesome Microsoft Excel videos 😃