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
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