ExcelTip.com
Account Icon Account Icon Account Icon
ExcelTip.com

Go Back   Excel Help Forum > Microsoft Office Application Help - Excel Help forum > Excel Programming > Excel Charting

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-17-2005, 06:05 PM
Gary's Student
Guest
 
Posts: n/a
Automatically set chart axis labels from cell contents

I have lots of scatter charts plotting data in columns. At the top of each
column is a cell containing the label I want to appear on the axis. I would
like the axis to be re-labeled whenever the label cells change automatically.
I am currently doing this with a little macro:

Sub setlabel()
Dim x As String
x = Cells(1, 1)
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
With ActiveChart
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = x
End With
End Sub

This is not automatic. Is there a way to perform this automatically without
resorting to VBA trickery??
--
Gary's Student
Reply With Quote
  #2  
Old 06-17-2005, 08:05 PM
Jon Peltier
Guest
 
Posts: n/a
Re: Automatically set chart axis labels from cell contents

Just to clarify, this is the axis title. The (tick) labels occur at each
major tick along the axis.

You can link the text of an axis title to a particular cell. Select the
axis title, press the equals key, and select the cell.

This also works with the chart title, individual data labels, and text
boxes.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Gary's Student wrote:

> I have lots of scatter charts plotting data in columns. At the top of each
> column is a cell containing the label I want to appear on the axis. I would
> like the axis to be re-labeled whenever the label cells change automatically.
> I am currently doing this with a little macro:
>
> Sub setlabel()
> Dim x As String
> x = Cells(1, 1)
> ActiveSheet.ChartObjects("Chart 1").Activate
> ActiveChart.ChartArea.Select
> With ActiveChart
> .Axes(xlCategory, xlPrimary).HasTitle = True
> .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = x
> End With
> End Sub
>
> This is not automatic. Is there a way to perform this automatically without
> resorting to VBA trickery??

Reply With Quote
  #3  
Old 06-17-2005, 09:05 PM
Gary's Student
Guest
 
Posts: n/a
Re: Automatically set chart axis labels from cell contents

Your suggestion works perfectly. Thank you very much
--
Gary's Student


"Jon Peltier" wrote:

> Just to clarify, this is the axis title. The (tick) labels occur at each
> major tick along the axis.
>
> You can link the text of an axis title to a particular cell. Select the
> axis title, press the equals key, and select the cell.
>
> This also works with the chart title, individual data labels, and text
> boxes.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Peltier Technical Services
> Tutorials and Custom Solutions
> http://PeltierTech.com/
> _______
>
>
> Gary's Student wrote:
>
> > I have lots of scatter charts plotting data in columns. At the top of each
> > column is a cell containing the label I want to appear on the axis. I would
> > like the axis to be re-labeled whenever the label cells change automatically.
> > I am currently doing this with a little macro:
> >
> > Sub setlabel()
> > Dim x As String
> > x = Cells(1, 1)
> > ActiveSheet.ChartObjects("Chart 1").Activate
> > ActiveChart.ChartArea.Select
> > With ActiveChart
> > .Axes(xlCategory, xlPrimary).HasTitle = True
> > .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = x
> > End With
> > End Sub
> >
> > This is not automatic. Is there a way to perform this automatically without
> > resorting to VBA trickery??

>

Reply With Quote
Reply

Bookmarks

New topics in Excel Charting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


All times are GMT -4. The time now is 10:49 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0