0

I've run into a very strange problem with data labels in pie charts on Excel 2003. I'll set the .Top or .Left property of a data label absolutely in VBA, but Excel will automatically move it to a different value. Why does this happen? How can I work around this? This problem does not exist in Excel 2007, it seems, from my testing. To see what I mean, try creating a pie chart with data labels in excel 2007, and run the following function on the chart:

Sub problemExample(xlcht As Excel.Chart)

With xlcht.SeriesCollection(1)

    For aSlice = 1 To .Points.Count
        .Points(aSlice).DataLabel.Top = 43
        Range("F" & (aSlice + 1)).Value = .Points(aSlice).DataLabel.Top
        .Points(aSlice).DataLabel.Left = 38
        Range("G" & (aSlice + 1)).Value = .Points(aSlice).DataLabel.Left
    Next aSlice
End With
End Sub

1 Answer 1

0

The reason is that positions are quantized. The top, left, width, and height properties aren't a continuous spectrum of possible values, they can only be changed by fixed increments. If you pick something between these increments, excel will immediately round the property to the nearest incremental value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.