Adding Data Labels to a Pivot Chart with VBA Macro

Peter Davison

Active Member
Joined
Jun 4, 2020
Messages
435
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.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,214,920
Messages
6,122,262
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top