Centering Axis and Chart Titles on chart
Win XP HE, XL 2002 SP3
Hi, I cannot find out how to center the title of the chart AND the axis title on the chart area so that it is precisely centered (not manually). How does one go about it? Tx, S |
Hi,
This code will center charttitle and xaxis title within chartarea. '------------------------------ Sub CenterChartTitles() ' ' Center within chart area then chart title and xaxis title, if present. ' ' Text items have no Width property so use an approximation. ' Force text to far right and use the difference between actual ' and expected position to approx width. ' Dim sngWidth As Single With ActiveChart If .HasTitle Then With .ChartTitle .Left = ActiveChart.ChartArea.Width sngWidth = ActiveChart.ChartArea.Width - .Left .Left = (ActiveChart.ChartArea.Width - sngWidth) / 2 End With End If If .Axes(1, 1).HasTitle Then With .Axes(1, 1).AxisTitle .Left = ActiveChart.ChartArea.Width sngWidth = ActiveChart.ChartArea.Width - .Left .Left = (ActiveChart.ChartArea.Width - sngWidth) / 2 End With End If End With End Sub '------------------------------ Cheers Andy saturnin02 wrote: Win XP HE, XL 2002 SP3 Hi, I cannot find out how to center the title of the chart AND the axis title on the chart area so that it is precisely centered (not manually). How does one go about it? Tx, S -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
All times are GMT +1. The time now is 02:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com