Amending Datalabels Source Data in Stacked Column Chart

StuartBewley

New Member
Joined
Sep 7, 2015
Messages
6
Hi Guys,

This is a really simple one I'm sure, but I'm struggling to find the solution.

I have some code to insert and format data labels for specific series' in a stacked column chart.

The code works perfectly (an extract from the macro recorder), but is referencing a specific worksheet (Template"). I simply want to be able to change the code so it references the same range in the ActiveSheet, rather than always referencing the "Template" sheet.

An example of the code is below:


ActiveChart.FullSeriesCollection(4).Select
ActiveChart.FullSeriesCollection(4).ApplyDataLabels
ActiveChart.FullSeriesCollection(4).DataLabels.Select
ActiveChart.SeriesCollection(4).DataLabels.Format.TextFrame2.TextRange. _
InsertChartField msoChartFieldRange, _
"= 'Template'!$B$9 ,'Template'!$D$9,'Template'!$F$9,'Template'!$H$9,'Template'!$J$9,'Template'!$L$9,'Template'!$N$9" _
, 0
Selection.ShowRange = True
Selection.ShowValue = False
Selection.ShowCategoryName = False
Selection.Position = xlLabelPositionCenter
Selection.Format.TextFrame2.TextRange.Font.Size = 8


Would anyone be able to help?

Many thanks,
Stuart
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,223,099
Messages
6,170,107
Members
452,302
Latest member
TaMere

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