Adding Data Labels to a Pivot Chart with VBA Macro

Peter Davison

Board Regular
Joined
Jun 4, 2020
Messages
133
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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Watch MrExcel Video

Forum statistics

Threads
1,114,116
Messages
5,546,035
Members
410,721
Latest member
adi772
Top