PC Review


Reply
Thread Tools Rate Thread

Chart Title Length

 
 
Matt
Guest
Posts: n/a
 
      30th Jan 2007
Using VBA, I'm making a graph title dynamic. I am having trouble with
the length of the characters. Within the code for the Chart Title, is
there a maximum number of characters that you can have in a title
cart? Also, how do I start a new line and continue the title? What I
have so far is putting the Customer Name, Address, City, State Zip all
on one line. What I would like is for example,

Customer Name
Address
City, State Zip


Thanks in advance,
Matt

 
Reply With Quote
 
 
 
 
Ken
Guest
Posts: n/a
 
      30th Jan 2007
Matt

This should help you get started. Select an embedded Chart to which
you want to add a title, and run this code. It will put the contents
of A1 on the first line, A2 on the second line and A3 on the third
line.

Sub Macro3()

t = Range("a1").Value & Chr(10) & Range("a2").Value & Chr(10) &
Range("a3").Value

With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = t
End With

End Sub

I get an error when the total length of the three cells is over 253.
I suppose it counts the chr(10)'s as characters, but, I thought you
could go up to 256 total.

Good luck.

Ken
Norfolk, Va



On Jan 30, 4:13 pm, "Matt" <MattSonn...@gmail.com> wrote:
> Using VBA, I'm making a graph title dynamic. I am having trouble with
> the length of the characters. Within the code for the Chart Title, is
> there a maximum number of characters that you can have in a title
> cart? Also, how do I start a new line and continue the title? What I
> have so far is putting the Customer Name, Address, City, State Zip all
> on one line. What I would like is for example,
>
> Customer Name
> Address
> City, State Zip
>
> Thanks in advance,
> Matt



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      31st Jan 2007
An alternative is to put a formula into another cell that builds this string
in the cell

=A1&CHAR(10)&A2&CHAR(10)&A3

Then use this line to link the chart title to the cell with this formula (in
this example it's cell E3, and it must be in R1C1 notation):

activechart.ChartTitle.Text = "=Sheet1!R3C5"

If you don't want it linked, follow with this:

activechart.ChartTitle.Text = activechart.ChartTitle.Text

You can't directly use

activechart.ChartTitle.Text = t

if t is longer than some limited string length, but the two step process
above works just fine.

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


"Ken" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Matt
>
> This should help you get started. Select an embedded Chart to which
> you want to add a title, and run this code. It will put the contents
> of A1 on the first line, A2 on the second line and A3 on the third
> line.
>
> Sub Macro3()
>
> t = Range("a1").Value & Chr(10) & Range("a2").Value & Chr(10) &
> Range("a3").Value
>
> With ActiveChart
> .HasTitle = True
> .ChartTitle.Characters.Text = t
> End With
>
> End Sub
>
> I get an error when the total length of the three cells is over 253.
> I suppose it counts the chr(10)'s as characters, but, I thought you
> could go up to 256 total.
>
> Good luck.
>
> Ken
> Norfolk, Va
>
>
>
> On Jan 30, 4:13 pm, "Matt" <MattSonn...@gmail.com> wrote:
>> Using VBA, I'm making a graph title dynamic. I am having trouble with
>> the length of the characters. Within the code for the Chart Title, is
>> there a maximum number of characters that you can have in a title
>> cart? Also, how do I start a new line and continue the title? What I
>> have so far is putting the Customer Name, Address, City, State Zip all
>> on one line. What I would like is for example,
>>
>> Customer Name
>> Address
>> City, State Zip
>>
>> Thanks in advance,
>> Matt

>
>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      31st Jan 2007
> I get an error when the total length of the three cells is over 253.
> I suppose it counts the chr(10)'s as characters, but, I thought you
> could go up to 256 total.


I've always found the limit of characters in a chart title is limited to
255, no way to increase with any method or combination of methods manually
or with vba AFAIK. Only alternative would be a textbox.

I suppose unlikely name + address would be more than 255.

Regards,
Peter T

"Ken" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Matt
>
> This should help you get started. Select an embedded Chart to which
> you want to add a title, and run this code. It will put the contents
> of A1 on the first line, A2 on the second line and A3 on the third
> line.
>
> Sub Macro3()
>
> t = Range("a1").Value & Chr(10) & Range("a2").Value & Chr(10) &
> Range("a3").Value
>
> With ActiveChart
> .HasTitle = True
> .ChartTitle.Characters.Text = t
> End With
>
> End Sub
>
> I get an error when the total length of the three cells is over 253.
> I suppose it counts the chr(10)'s as characters, but, I thought you
> could go up to 256 total.
>
> Good luck.
>
> Ken
> Norfolk, Va
>
>
>
> On Jan 30, 4:13 pm, "Matt" <MattSonn...@gmail.com> wrote:
> > Using VBA, I'm making a graph title dynamic. I am having trouble with
> > the length of the characters. Within the code for the Chart Title, is
> > there a maximum number of characters that you can have in a title
> > cart? Also, how do I start a new line and continue the title? What I
> > have so far is putting the Customer Name, Address, City, State Zip all
> > on one line. What I would like is for example,
> >
> > Customer Name
> > Address
> > City, State Zip
> >
> > Thanks in advance,
> > Matt

>
>



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      31st Jan 2007
I tested my technique with an arbitrary string that was around 350
characters long.

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


"Peter T" <peter_t@discussions> wrote in message
news:ez%(E-Mail Removed)...
>> I get an error when the total length of the three cells is over 253.
>> I suppose it counts the chr(10)'s as characters, but, I thought you
>> could go up to 256 total.

>
> I've always found the limit of characters in a chart title is limited to
> 255, no way to increase with any method or combination of methods manually
> or with vba AFAIK. Only alternative would be a textbox.
>
> I suppose unlikely name + address would be more than 255.
>
> Regards,
> Peter T
>
> "Ken" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Matt
>>
>> This should help you get started. Select an embedded Chart to which
>> you want to add a title, and run this code. It will put the contents
>> of A1 on the first line, A2 on the second line and A3 on the third
>> line.
>>
>> Sub Macro3()
>>
>> t = Range("a1").Value & Chr(10) & Range("a2").Value & Chr(10) &
>> Range("a3").Value
>>
>> With ActiveChart
>> .HasTitle = True
>> .ChartTitle.Characters.Text = t
>> End With
>>
>> End Sub
>>
>> I get an error when the total length of the three cells is over 253.
>> I suppose it counts the chr(10)'s as characters, but, I thought you
>> could go up to 256 total.
>>
>> Good luck.
>>
>> Ken
>> Norfolk, Va
>>
>>
>>
>> On Jan 30, 4:13 pm, "Matt" <MattSonn...@gmail.com> wrote:
>> > Using VBA, I'm making a graph title dynamic. I am having trouble with
>> > the length of the characters. Within the code for the Chart Title, is
>> > there a maximum number of characters that you can have in a title
>> > cart? Also, how do I start a new line and continue the title? What I
>> > have so far is putting the Customer Name, Address, City, State Zip all
>> > on one line. What I would like is for example,
>> >
>> > Customer Name
>> > Address
>> > City, State Zip
>> >
>> > Thanks in advance,
>> > Matt

>>
>>

>
>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      31st Jan 2007
I didn't see your earlier post when I posted mine.

I tried to replicate your technique exactly but I'm afraid it didn't work
for me. In case I've missed something this is what I did -

Sub Test()
Range("A1").Formula = "=REPT(""A"",100)"
Range("A2").Formula = "=REPT(""B"",100)"
Range("A3").Formula = "=REPT(""C"",100)"
Range("E3").Formula = "=A1&CHAR(10)&A2&CHAR(10)&A3"

With ActiveSheet.ChartObjects(1).Chart
.HasTitle = True
.ChartTitle.Text = "=Sheet1!R3C5"
.ChartTitle.Text = .ChartTitle.Text ' this won't increase length

Debug.Print Len(Range("E3")), Len(.ChartTitle.Text) ' 302 & 255
End With

End Sub

Stuck on 255, can't even manually paste more than that into a title.

Regards,
Peter T


"Jon Peltier" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I tested my technique with an arbitrary string that was around 350
> characters long.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://PeltierTech.com
> _______
>
>
> "Peter T" <peter_t@discussions> wrote in message
> news:ez%(E-Mail Removed)...
> >> I get an error when the total length of the three cells is over 253.
> >> I suppose it counts the chr(10)'s as characters, but, I thought you
> >> could go up to 256 total.

> >
> > I've always found the limit of characters in a chart title is limited to
> > 255, no way to increase with any method or combination of methods

manually
> > or with vba AFAIK. Only alternative would be a textbox.
> >
> > I suppose unlikely name + address would be more than 255.
> >
> > Regards,
> > Peter T
> >
> > "Ken" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> Matt
> >>
> >> This should help you get started. Select an embedded Chart to which
> >> you want to add a title, and run this code. It will put the contents
> >> of A1 on the first line, A2 on the second line and A3 on the third
> >> line.
> >>
> >> Sub Macro3()
> >>
> >> t = Range("a1").Value & Chr(10) & Range("a2").Value & Chr(10) &
> >> Range("a3").Value
> >>
> >> With ActiveChart
> >> .HasTitle = True
> >> .ChartTitle.Characters.Text = t
> >> End With
> >>
> >> End Sub
> >>
> >> I get an error when the total length of the three cells is over 253.
> >> I suppose it counts the chr(10)'s as characters, but, I thought you
> >> could go up to 256 total.
> >>
> >> Good luck.
> >>
> >> Ken
> >> Norfolk, Va
> >>
> >>
> >>
> >> On Jan 30, 4:13 pm, "Matt" <MattSonn...@gmail.com> wrote:
> >> > Using VBA, I'm making a graph title dynamic. I am having trouble with
> >> > the length of the characters. Within the code for the Chart Title,

is
> >> > there a maximum number of characters that you can have in a title
> >> > cart? Also, how do I start a new line and continue the title? What

I
> >> > have so far is putting the Customer Name, Address, City, State Zip

all
> >> > on one line. What I would like is for example,
> >> >
> >> > Customer Name
> >> > Address
> >> > City, State Zip
> >> >
> >> > Thanks in advance,
> >> > Matt
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      1st Feb 2007
I stand corrected. When I did my test, I was using gibberish text, like
"adsaf;atowaagnl;agio" and must have only thought the entire blob was
inserted into the chart title.

I agree with your earlier observation, of course, that most self-respecting
titles will not be anywhere near this length.

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


"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
>I didn't see your earlier post when I posted mine.
>
> I tried to replicate your technique exactly but I'm afraid it didn't work
> for me. In case I've missed something this is what I did -
>
> Sub Test()
> Range("A1").Formula = "=REPT(""A"",100)"
> Range("A2").Formula = "=REPT(""B"",100)"
> Range("A3").Formula = "=REPT(""C"",100)"
> Range("E3").Formula = "=A1&CHAR(10)&A2&CHAR(10)&A3"
>
> With ActiveSheet.ChartObjects(1).Chart
> .HasTitle = True
> .ChartTitle.Text = "=Sheet1!R3C5"
> .ChartTitle.Text = .ChartTitle.Text ' this won't increase length
>
> Debug.Print Len(Range("E3")), Len(.ChartTitle.Text) ' 302 & 255
> End With
>
> End Sub
>
> Stuck on 255, can't even manually paste more than that into a title.
>
> Regards,
> Peter T
>
>
> "Jon Peltier" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I tested my technique with an arbitrary string that was around 350
>> characters long.
>>
>> - Jon
>> -------
>> Jon Peltier, Microsoft Excel MVP
>> Tutorials and Custom Solutions
>> http://PeltierTech.com
>> _______
>>
>>
>> "Peter T" <peter_t@discussions> wrote in message
>> news:ez%(E-Mail Removed)...
>> >> I get an error when the total length of the three cells is over 253.
>> >> I suppose it counts the chr(10)'s as characters, but, I thought you
>> >> could go up to 256 total.
>> >
>> > I've always found the limit of characters in a chart title is limited
>> > to
>> > 255, no way to increase with any method or combination of methods

> manually
>> > or with vba AFAIK. Only alternative would be a textbox.
>> >
>> > I suppose unlikely name + address would be more than 255.
>> >
>> > Regards,
>> > Peter T
>> >
>> > "Ken" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >> Matt
>> >>
>> >> This should help you get started. Select an embedded Chart to which
>> >> you want to add a title, and run this code. It will put the contents
>> >> of A1 on the first line, A2 on the second line and A3 on the third
>> >> line.
>> >>
>> >> Sub Macro3()
>> >>
>> >> t = Range("a1").Value & Chr(10) & Range("a2").Value & Chr(10) &
>> >> Range("a3").Value
>> >>
>> >> With ActiveChart
>> >> .HasTitle = True
>> >> .ChartTitle.Characters.Text = t
>> >> End With
>> >>
>> >> End Sub
>> >>
>> >> I get an error when the total length of the three cells is over 253.
>> >> I suppose it counts the chr(10)'s as characters, but, I thought you
>> >> could go up to 256 total.
>> >>
>> >> Good luck.
>> >>
>> >> Ken
>> >> Norfolk, Va
>> >>
>> >>
>> >>
>> >> On Jan 30, 4:13 pm, "Matt" <MattSonn...@gmail.com> wrote:
>> >> > Using VBA, I'm making a graph title dynamic. I am having trouble
>> >> > with
>> >> > the length of the characters. Within the code for the Chart Title,

> is
>> >> > there a maximum number of characters that you can have in a title
>> >> > cart? Also, how do I start a new line and continue the title? What

> I
>> >> > have so far is putting the Customer Name, Address, City, State Zip

> all
>> >> > on one line. What I would like is for example,
>> >> >
>> >> > Customer Name
>> >> > Address
>> >> > City, State Zip
>> >> >
>> >> > Thanks in advance,
>> >> > Matt
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Chart Title and Axis title and Legend iccsi Microsoft Access Reports 1 16th Dec 2008 01:22 PM
Chart Title - exceed maximum length? =?Utf-8?B?R2VvZmYgQw==?= Microsoft Excel Charting 2 11th Oct 2007 02:33 PM
Pasting Objects into Chart title and Axis title =?Utf-8?B?U2Ft?= Microsoft Excel Charting 1 6th Jun 2005 08:50 PM
Chart Title Length Kurt Mease Microsoft Excel Charting 1 16th Feb 2004 08:10 PM
Aligning title, legend, x axis title on chart Ann Scharpf Microsoft Excel Charting 1 11th Nov 2003 06:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:42 PM.