Link to home
Start Free TrialLog in
Avatar of John Carney
John CarneyFlag for United States of America

asked on

Creating custom data labels in a chartseries

Please take a look at the attached workbook. I need to get my chart values from Row 4, but I want to get my data labels from Row 5.

How do I do that? Assuming thatI can have a custom label other than series, category or value.

Thanks,
John
Custom-Data-Labels.xlsx
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Carney

ASKER

Thank you for your solutions. They didn't quite address my actual situation but the two of you got me started in the right direction and I was able to come with a good solution. For what it's worth, this is what I ended up with.

Sub GetDataLabels()
Dim i As Long, Ln As Range
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.SetElement (msoElementPrimaryValueAxisShow)
    ActiveChart.ChartArea.Select
    ActiveChart.SeriesCollection(1).Values = "='Weeks Done'!$X$4:$AJ$4"
For i = 1 To 13
Set Ln = Sheets("Weeks Done").Cells(6, i + 23)
    ActiveChart.SeriesCollection(1).Points(i).HasDataLabel = True
    ActiveChart.SeriesCollection(1).Points(i).DataLabel.Text = _
        Left(Sheets("Weeks Done").Cells(5, i + 23), Ln) & vbLf & _
        Right(Sheets("Weeks Done").Cells(5, i + 23), Ln)
    ActiveChart.SeriesCollection(1).Points(i).DataLabel.Position = xlLabelPositionInsideEnd
Next i
    With ActiveChart.Axes(xlValue)
        .MinimumScale = [Lo]
        .MaximumScale = [Hi]
        .MinorUnitIsAuto = True     '.MajorUnit = [XAxisMajor]
    End With
ActiveChart.Axes(xlValue, xlPrimary).Delete
[A1].Select
End Sub

Thanks,
John