Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
saturnin02
 
Posts: n/a
Default 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


  #2   Report Post  
Andy Pope
 
Posts: n/a
Default

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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Right axis instead of left axis in chart saturnin02 Excel Discussion (Misc queries) 5 April 29th 23 11:42 AM
Formatting dates on x axis of chart...! saturnin02 Excel Discussion (Misc queries) 4 January 27th 05 08:55 PM
How do I set permanent secondary axis in PivotTable chart? Microlong Charts and Charting in Excel 3 January 8th 05 03:54 AM
Second X axis at top of chart? Phil Hageman Charts and Charting in Excel 1 December 29th 04 01:48 PM
Labels on Chart with Negative Value Axis David F. Schrader Charts and Charting in Excel 6 December 17th 04 06:25 PM


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"