user2808271
user2808271

Reputation: 29

Keep Chart Data Label from Wraping

I have a project where I have to put user generated data labels in a chart. These need to be on a series line as such:

![What I want format][1]

However in some instances the text wraps. How do I keep the text from wrapping in excel 10? see below

![enter image description here][2]

'-------- FORMAT DATA LABELS -------------------------------------

ActiveSheet.ChartObjects("OperBal2Takt").Activate
h = 0
For h = 2 To 7
    With ActiveChart.SeriesCollection(h).Points(1)
        .HasDataLabel = True
        .DataLabel.Text = Cells(2018 + h, 8).Value
        '.DataLabel.Width = msofit
    End With
Next h

Upvotes: 2

Views: 14912

Answers (2)

Patrick Lepelletier
Patrick Lepelletier

Reputation: 1654

use this code:

ChartObj.chart.seriescollection(1).datalabels.Format.TextFrame2.WordWrap = msoFalse

and also, but less usefull:

ChartObj.chart.seriescollection(1).datalabels.Format.TextFrame2.AutoSize = msoAutoSizeNone

Upvotes: 1

Jon Peltier
Jon Peltier

Reputation: 6063

In Excel 2013, the size of your data label can be changed. In previous versions, the label cannot be resized.

In earlier Excel versions, sometimes I've stretched the chart to make it wider, but shrunk the plot area of the chart down to the original size, so the white space is wider on both sides of the chart. This works because the maximum size of a label is proportional to the chart width.

Other times I've replaced the data label with a text box, which can be flexibly resized.

Upvotes: 4

Related Questions