Skip to main content

How to add a horizontal average line to chart in Excel?

Author: Xiaoyang Last Modified: 2024-08-22

In Excel, you may often create a chart to analyze the trend of the data. But sometimes, you need to add a simple horizontal line across the chart that represents the average line of the plotted data, so that you can see the average value of the data clearly and easily. In this case, how could you add a horizontal average line to a chart in Excel?


Add a horizontal average line to a chart with a helper column

If you want to insert a horizontal average line to a chart, you can calculate the average of the data first, and then create the chart. Please do as this:

1. Calculate the average of the data with Average function, for example, in Average Column C2, type this formula: =Average($B$2:$B$8), and then drag this cell's AutoFill handle to the range as you need. See screenshot:
Calculate the average of the data with Average function

2. And then select this range and choose one chart format that you want to insert, such as 2-D Column under the Insert tab. See screenshot:
choose one chart format under the Insert tab

3. And a chart has been created, please click one of the average data column (the red bar) in the chart, right click and select the Change Series Chart Type from the context menu. See screenshot:
select the Change Series Chart Type from the context menu

4. In the popped out Change Chart Type dialog, click to highlight the Combo in the left bar, click box behind the Average, and then select the a line chart style from the drop down list. See screenshot:
select the a line chart style from the drop down list

5. Click the OK button. Now, you have a horizontal line representing the average in your chart, see screenshot:
a horizontal line representing the average in the chart


Quickly add a horizontal average line with an amazing tool

This method will recommend an amazing tool, Add Line to Chart feature of Kutools for Excel, to quickly add a horizontal average line to the selected column chart with 2 clicks only!

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

Supposing you have created a column chart as below screenshot shown, and you can add a horizontal average line for it as follows:
sample chart

1. Select the column chart, and click Kutools > Charts > Add Line to Chart to enable this feature.

2. In the Add line to chart dialog, please check the Average option, and click the Ok button.
check the Average option in the dialog box

Now the horizontal average line is added to the selected column chart at once.
the horizontal average line is added to the chart

Add a horizontal average line to a chart with VBA code

Supposing you have created a column chart with your data in your worksheet, and the following VBA code also can help you to insert an average line across your chart.

1.Click one of the data column in your chart, and then all the data columns will be selected, see screenshot:
select all the data columns of the chart

2. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

3. Click Insert > Module, and paste the following code in the Module Window.

VBA: add an average line to the chart

Sub AverageLine()
'Update 20130907
Dim ser As Series
Dim arr As Variant
Dim total As Double
Dim outArr As Variant
If VBA.TypeName(Application.Selection) <> "Series" Then Exit Sub
Set ser = Application.Selection
arr = ser.Values
total = Application.WorksheetFunction.Average(arr)
ReDim outArr(LBound(arr) To UBound(arr))
For i = LBound(outArr) To UBound(outArr)
    outArr(i) = total
Next
With ActiveChart.SeriesCollection.NewSeries
    .XValues = ser.XValues
    .Values = outArr
    .Name = "Average " & ser.Name
    .AxisGroup = ser.AxisGroup
    .MarkerStyle = xlNone
    .Border.Color = ser.Border.Color
    .ChartType = xlLine
    .Format.Line.ForeColor.ObjectThemeColor = msoThemeColorAccent6
End With
End Sub

4. Then press F5 key to run this code, and a horizontal average line has been inserted into the column chart. See screenshot:
run vba code to get the horizontal avergae line

Note: This VBA only can run when the Column format you insert is 2-D Column.

Related articles:

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!