Adding Data Labels to a Pivot Chart with VBA Macro

Peter Davison

Board Regular
Joined
Jun 4, 2020
Messages
141
Office Version
  1. 365
Platform
  1. Windows
I have a Pivot Table called PivotTable1
I have a chart called Cluster Review
The range is dynamic can be different by import
I want to add data labels to each series automatically (bearing in mind the number of series can change

I have seen this code that someone else used and have inserted my Table and Chart name
I am not sure what the [Project '#] bit is after the PivotTable1 name does or if it is part of the other guys table name?

It hasn't got a start and end sub because it is part of a larger macro.

ActiveSheet.ChartObjects("Cluster Overview").Activate
ActiveChart.FullSeriesCollection(1).DataLabels.Select

For i = 1 To Range("PivotTable1[Project '#]").Count

ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select

Selection.Formula = Range("PivotTable1[Project '#]").Cells(i, 1)

Next i

Any help you can give will be great.
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Watch MrExcel Video

Forum statistics

Threads
1,118,750
Messages
5,574,016
Members
412,563
Latest member
marianmalone2019
Top