excel vba
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Excel VBA

Excel VBA

resolvedResolved · High Priority · Version 2007

replyReply Fri 11 Nov 2011, 16:43Delegate Steve said...

Steve has attended:
Excel VBA Intro Intermediate course

Excel VBA

IN a 2-d clustered bar chart how can you superscript a portion of the text on the data label. The label option is set to category name.
Each data points category name is a different length, but I want to be able to add a number at the end of the category name and format it as superscript. I've tried using the macro recorder to create the code but when you try and run it the following error message occur's:
"Run-time error '-2147024809 (80070057)':
The index into the specified collection is out of bounds."

This is the code created by the macro recorder.
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).DataLabels.Select
ActiveChart.SeriesCollection(2).Points(6).DataLabel.Select
Selection.Format.TextFrame2.TextRange.Characters(20, 1).Font.BaselineOffset = _
0.3
ActiveChart.SeriesCollection(2).Points(6).DataLabel.Text = _
"Currency 1"

For upcoming training course dates see: Pricing & availability

replyReply Tue 15 Nov 2011, 09:17Trainer Anthony said...

RE: Excel VBA

Hi Steve, thanks for your query. Try the code at this link:

http://www.mrexcel.com/forum/showthread.php?t=556829

...but note the problems across versions. See how you get on, and try a succession of macros to split the process up - one to drill into the label, then to select text, then to superscript etc.

Hope this helps,

Anthony

 

Please browse our web site to find out more about
access vba introduction and other Microsoft training courses.

Vba tip:

Good coding practice

It is important that you always comment the VBA code that you write. By doing this it will make the code much easier to read, as both yourself and other people will be able to see what the code is doing or meant to be doing. This is very important if there is more than one person who writes code in the company as you may have different styles of coding and may not really understand what the other person is trying to do. Also if you write some code and then do not touch it for a year or so you may actually forget what it is meant to be doing. so it is very important to include comments throughout your code and try and make sure that they are as useful as possible

View all VBA hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard