Properties of data label

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
174
Hello

I would like to have the equation centered on the graph.
Here is some code with some properties.
But how to set the width?
How to center the equation?
VBA Code:
    With .FullSeriesCollection(1).Trendlines(1)
        .DisplayEquation = True
            With .DataLabel
                .Left = 170
                .Top = 200
                With .Format.TextFrame2.TextRange.Font
                    .Bold = msoTrue
                    .Fill.ForeColor.RGB = rgbRed
                    .Size = 10
                End With
            End With
    End With
I prefer to not "experiment" with the .left property, rather a permanent solution.


Any help would be appreciated
Tom
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I tried this, but the equation isn't centered
VBA Code:
    With .FullSeriesCollection(1).Trendlines(1)
        .DisplayEquation = True
            With .DataLabel
                .Top = 185
                With .Format.TextFrame2.TextRange.Font
                    .Bold = msoTrue
                    .Fill.ForeColor.RGB = rgbRed
                    .Size = 10
                End With
                pltwth = ActiveChart.PlotArea.Width
                eqwth = ActiveChart.FullSeriesCollection(1).Trendlines(1).DataLabel.Width
                eqlft = (pltwth - eqwth)/2
                .Left = eqlft
            End With
    End With
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top