Do you wish to learn how to add data labels in Excel to display the details of the data series or a specific data point? If yes, this effortless Excel tutorial will help you. Keep reading!
Data labels in Excel are essential for enhancing chart clarity and readability. By adding labels directly to data points, you provide viewers with immediate and precise information about the plotted data series. Thus, the audience doesn’t need to refer to the underlying table or dataset constantly.
For example, you might want to show the values of columns in a column chart in Excel or show percentages in each slice of an Excel pie chart.
Using the Add Data Labels Tool
The Data Labels tool is the default Excel feature to add data labels in any Excel chart. Also, you can access it in multiple ways so it’s the most suitable option for general tasks.
To practice this approach, click on the source chart and hit the Chart Elements button in the top right corner of the chart. It looks like a plus sign.
It’ll expand the Chart Elements context menu. Checkmark the checkbox for Data Labels.
Excel will add the default data labels in your chart.
If you’d like to customize the position of the data labels, hover your mouse over the Data Labels option and click on the overflow arrow.
You’ll find the following alternative locations for data labels:
- Center
- Inside End
- Inside Base
- Outside End
- Data Callout
You can also use the same tool and steps to add a data label in a Pivot Chart in Excel.
Using a Custom Text Box
Often, you might want to highlight only a single data point in your chart. You can do that by using the Data Labels tool explained earlier. If you use that approach, you’ll need to delete the unwanted data labels from the chart one after the other.
Alternatively, you can use an Excel Text Box to add a custom data label. Since you can drag and drop a Text Box anywhere on the Excel worksheet including the chart objects, it’s the most effortless approach so far.
Go to the source Excel chart and click on the Insert tab in the Excel ribbon menu.
Click on the Text Box button inside the Text block of the Insert tab.
A modified cursor will show when you hover the mouse cursor over the chart.
Draw the Text Box using your mouse.
A text cursor will show. You can now type the data label as per your preference.
Click on the Text Box border and drag it to the left or right to increase the dimension to fit your text.
You can further customize the data label by selecting the whole text. A text customization menu will show up on the top of the Text Box.
From this tool, you can choose the following features:
- Font
- Font Size
- Bold/ Italic/ Underline
- Align Left/ Center/ Alignt Right
- Font Color
You can also customize the Text Box by changing the default fill color, style, etc. To do this, click on the text. A Text Box outline will show up. Click on the Text Box border and right-click to bring up the Text Box customization tool.
Use the following tools to modify the Text Box:
- Style
- Fill
- Outline
Find above a sample of custom data labels on an Excel chart.
Using Cell Range Values as Data Labels
You can use values from a specific cell range as custom labels, allowing you to display information that’s more descriptive or contextual than the default chart values. For example, instead of showing just numerical values, you could label data points with relevant text or calculated results. Also, by following this method, you can custom-label multiple data points on the chart in one go.
For instance, you want to add custom data labels for all the columns in the above graph.
Copy the Category data or values and paste that into another cell range.
Now, enter the custom data labels you want in the cell range next to the copied Category data.
Add data labels for all the columns in the source chart by following the first method explained above in this Excel tutorial.
Select any one of the data labels on the chart to select all. Right-click and select Format Data Labels from the context menu.
A navigation panel will show up on the right side. This is the Format Data Labels toolbox.
There, you should see the Label Contains section with six checkboxes. Checkmark the Value From Cells checkbox.
The Data Label Range dialog box will show up. Click on the Select Data Label Range field and highlight the cell range from which you want to import custom data labels.
Excel will update the chart’s data labels with the new data as well as the existing values.
Now, go to the Format Data Labels toolbox again and uncheck the checkbox for Values.
Using a Custom Number Format as Data Labels
By applying a custom format, you can control the number of decimal places, add symbols, include text, or even create conditional formatting and display these as data labels.
For example, you might want to display currency values with a dollar sign and two decimal places, percentages without the percent symbol, or dates in a specific format. Custom number formats provide the flexibility to achieve these and many other formatting options.
The best thing about this approach is the custom number formatting only impacts the display of data labels. You never change the underlying dataset.
In the Excel chart shown above, you can see pricing is displayed as plain digits. You can transform these data labels to any currency format along with one or two decimal places for enhanced readability and clarity.
To use a custom number formatting in this chart, select the existing data labels by clicking on any data point.
Right-click and select Format Data Labels from the context menu.
The Format Data Labels toolbox will show up on the right.
Scroll down on the toolbox to find the Number menu. Click on the left-side arrow to expand it.
Click on the Category drop-down menu and choose Custom.
Enter the following custom number formatting code inside the Format Code field:
$#,##0.00
Click the Add button to apply the new number formatting style.
You’ll see the updated data labels on the selected chart.
Using Excel VBA Editor
The Excel VBA-based method helps you to automate the manual and repetitive task of adding data labels. You can create several Excel VBA macros and run those in appropriate situations to install and apply data labels with custom styles and conventions.
In this section, you’ll find a few Excel VBA scripts for developing macros along with illustrations to show the performance of these macros.
Before you can create a macro, check out the following Excel tutorial to learn how to set up a macro in Excel using VBA:
📒 Read More: How To Use The VBA Code You Find Online
Now, try the following VBA scripts to automate data labels in any chart in Excel:
Add Data Labels for All Data Series
Use this VBA script to add data labels to all the data series in your chart:
Sub AddDataLabelsToChart()
Dim chartName As String
Dim chartObj As ChartObject
Dim seriesCount As Integer
Dim i As Integer
Dim labelColor As String
Dim colorCode As Long
chartName = InputBox("Enter the name of the chart object:")
On Error Resume Next
Set chartObj = ActiveSheet.ChartObjects(chartName)
On Error GoTo 0
If chartObj Is Nothing Then
MsgBox "Chart not found. Please check the name and try again."
Exit Sub
End If
seriesCount = chartObj.Chart.SeriesCollection.Count
If seriesCount = 1 Then
With chartObj.Chart.SeriesCollection(1)
.HasDataLabels = True
.DataLabels.Font.Color = RGB(0, 0, 139)
End With
Else
For i = 1 To seriesCount
labelColor = InputBox("Enter the color for data labels of series " & i & " (e.g., Red, Blue, Green):")
Select Case LCase(labelColor)
Case "red"
colorCode = RGB(255, 0, 0)
Case "blue"
colorCode = RGB(0, 0, 255)
Case "green"
colorCode = RGB(0, 255, 0)
Case Else
MsgBox "Invalid color. Defaulting to black."
colorCode = RGB(0, 0, 0)
End Select
With chartObj.Chart.SeriesCollection(i)
.HasDataLabels = True
.DataLabels.Font.Color = colorCode
End With
Next i
End If
MsgBox "Data labels have been added to the chart."
End Sub
Once you’ve created a macro using this script, press Alt + F8 to launch the Macro dialog box.
Select AddDataLabelsToChart from the list of macros and hit the Run button.
The script will show a series of dialog boxes to collect information from you to appropriately add data labels in the Excel chart. Find below the input boxes along with screenshots:
- Enter chart object name: You can find this by clicking on the chart and looking at the Name box in the top left corner of the worksheet.
- Input boxes for colors of label texts: Here, you must enter the font color for the data labels. These dialog boxes will appear for all the chart data series.
- Confirmation dialog: The last dialog box confirms the acceptance of input values. Once you close it, the data labels will show up.
The above is an example of an Excel chart with data labels added using the Excel VBA Editor.
Add Data Label for Select Series
You might also want to add data labels for a specific series index in an Excel chart. Use this VBA script to set up a macro that does so:
Sub AddDataLabelsToChart()
Dim chartName As String
Dim chartObj As ChartObject
Dim seriesCount As Integer
Dim seriesIndex As Integer
Dim seriesName As String
Dim series As series
' Prompt user to enter the chart name
chartName = InputBox("Enter the name of the chart object:")
' Check if the chart object exists
On Error Resume Next
Set chartObj = ActiveSheet.ChartObjects(chartName)
On Error GoTo 0
If chartObj Is Nothing Then
MsgBox "Chart object not found. Please check the name and try again."
Exit Sub
End If
' Get the number of series in the chart
seriesCount = chartObj.Chart.SeriesCollection.Count
' Prompt user to enter the series index
seriesIndex = InputBox("Enter the series index (1 to " & seriesCount & "):")
' Validate the series index
If seriesIndex < 1 Or seriesIndex > seriesCount Then
MsgBox "Invalid series index. Please enter a number between 1 and " & seriesCount & "."
Exit Sub
End If
' Add data labels to the specified series
Set series = chartObj.Chart.SeriesCollection(seriesIndex)
series.ApplyDataLabels
' Confirmation message
MsgBox "Data labels added to series " & seriesIndex & " successfully!"
End Sub
The above script will scan the chart object to extract its series indexes. Then, it’ll show the following dialog boxes for you to input data:
- Type in the chart object name.
- Enter the series index number for data labels.
Excel adds the data labels as soon as you interact with the last dialog box.
Using Office Scripts
Are you using Excel for Microsoft 365 desktop or web app and have a Microsoft 365 Business Standard or better subscription? You can use Office Scripts to automate various Excel activities including adding data labels in a chart.
Office Scripts also allows you to add data labels to graphs in Excel remotely using Power Automate without even opening the workbook.
Do you see the Automate tab on your Excel desktop or web app? Congratulations! You can follow these steps to practice this method.
On the source chart’s worksheet, go to the Automate tab and click on the New Script command inside the Scripting Tools block.
The Office Scripts Code Editor panel will open on the right side. Into the code editor, copy and paste the following script:
function main(workbook: ExcelScript.Workbook) {
// Get the active worksheet
let sheet = workbook.getActiveWorksheet();
// Get all charts in the active worksheet
let charts = sheet.getCharts();
// Loop through each chart and add data labels
charts.forEach(chart => {
let dataLabels = chart.getDataLabels();
dataLabels.setShowValue(true); // Show the value on the data labels
});
}
Click on the Save script button. You can assign a new name when saving the code.
Now, hit Run to execute the script.
Excel will add data labels to all the data series of all the charts in the worksheet.
Add Data Labels in Excel for Mac
The approach to adding data labels in a chart in Excel for Mac is slightly different than the Windows Excel app.
For instance, you won’t find the Chart Elements menu on the chart.
Instead, you need to select the source chart object to bring up the Chart Design tab on the ribbon menu.
Then, you can click on the Chart Elements button in the Chart Layouts block.
Now, hover the cursor over the Data labels menu to expand its submenu.
Select a position for the data labels, like Outside End.
Excel for Mac will add the data labels for all the data series indexes of the chart.
Conclusions
So far, you’ve learned how to add data labels in Excel using various methods, involving Excel user interface tools, Excel VBA Editor, and Office Scripts.
Practice and use the method you like and match your charting requirements in Excel.
If the article helped you or to share feedback, comment below.
0 Comments