I created a macro that creates a new line serie named "pos" which is the datalabel postion of another line serie within my selected chart. The next move is to select a custom data label range to be applied in my "pos" serie (which is the datalabel postion only).
The following code is working
ActiveSheet.ChartObjects("Chart").Activate
ActiveChart.FullSeriesCollection("Pos").Select
Selection.Format.Line.Visible = msoFalse
ActiveChart.FullSeriesCollection("Pos").Select
ActiveChart.FullSeriesCollection("Pos").ApplyDataLabels
ActiveChart.FullSeriesCollection("Pos").DataLabels.Select
ActiveChart.SeriesCollection("Pos").DataLabels.Format.TextFrame2.TextRange. _
InsertChartField msoChartFieldRange, "=Chart!$C$3:$C$28", 0
Selection.ShowRange = True
Selection.ShowValue = False
But if I want to select manually the range, i can not figure where is the error
Dim myrange As Range
Dim myrng As Range
Dim labelrange As Range
Set myrng = Application.InputBox(Prompt:="Select range", _
Title:="Range", Type:=8)
myrange = myrng.Range.Address(True, True)
Set labelrange = ActiveSheet.Range(myrng)
ActiveSheet.ChartObjects("Chart").Activate
ActiveChart.PlotArea.Select
ActiveChart.FullSeriesCollection("Pos").Select
Selection.Format.Line.Visible = msoFalse
ActiveChart.FullSeriesCollection("Pos").Select
ActiveChart.FullSeriesCollection("Pos").ApplyDataLabels
ActiveChart.FullSeriesCollection("Pos").DataLabels.Select
ActiveChart.SeriesCollection("Pos").DataLabels.Format.TextFrame2.TextRange.InsertChartField msoChartFieldRange, labelrange.Address(External:=True), 0
Selection.ShowRange = True
Selection.ShowValue = False
Does anyone has a clue on that topic?
Kind regards, Naxos