PC Review


Reply
Thread Tools Rate Thread

Data Labels Macro

 
 
=?Utf-8?B?S3Jpc3Rpbg==?=
Guest
Posts: n/a
 
      29th Oct 2007
This has also been posted on the Mr. Excel boards but has not generated any
response. I am working on modifing a chart using VB. I recorded the macro
at first and got the following lines of code:

ActiveChart.SeriesCollection(2).Points(1).DataLabel.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 2
.Background = xlTransparent
End With
With Selection
.Position = xlLabelPositionInsideBase
End With

When I try to rerun this code without any modification, I get the following
error:

Select method of DataLabels class failed.

I looked on a few boards and modified the code to look like this:

ActiveChart.SeriesCollection (1)
.HasDataLabels = True
.ApplyDataLabels Type:=xlValue
Selection.AutoScaleFont = True
With .DataLabels.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 2
End With
With .DataLabels
.Position = xlLabelInsideBase
End With

When i run this code, I get this error:

Invalid or unqualified reference

Is there some reference library that I need to select or something I need to
change in the code? Any ideas would be greatly appreciated.

Kristin
 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      29th Oct 2007

Kristin,
What are you trying to do?
Does the chart have data labels and you want to change something about them?
Are you trying to add data labels?
Something else?
What version of XL are you using?
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Kristin"
wrote in message
This has also been posted on the Mr. Excel boards but has not generated any
response. I am working on modifing a chart using VB. I recorded the macro
at first and got the following lines of code:

ActiveChart.SeriesCollection(2).Points(1).DataLabel.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 2
.Background = xlTransparent
End With
With Selection
.Position = xlLabelPositionInsideBase
End With

When I try to rerun this code without any modification, I get the following
error:

Select method of DataLabels class failed.

I looked on a few boards and modified the code to look like this:

ActiveChart.SeriesCollection (1)
.HasDataLabels = True
.ApplyDataLabels Type:=xlValue
Selection.AutoScaleFont = True
With .DataLabels.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 2
End With
With .DataLabels
.Position = xlLabelInsideBase
End With

When i run this code, I get this error:

Invalid or unqualified reference

Is there some reference library that I need to select or something I need to
change in the code? Any ideas would be greatly appreciated.

Kristin
 
Reply With Quote
 
=?Utf-8?B?S3Jpc3Rpbg==?=
Guest
Posts: n/a
 
      29th Oct 2007
I am writing a macro to create the chart from scratch and place the data
labels on the chart. The rest of the code works great. It hangs up where it
is supposed to add the data labels and do some formatting to the label. And
I am using XL 03.

"Jim Cone" wrote:

>
> Kristin,
> What are you trying to do?
> Does the chart have data labels and you want to change something about them?
> Are you trying to add data labels?
> Something else?
> What version of XL are you using?
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)
>
>
> "Kristin"
> wrote in message
> This has also been posted on the Mr. Excel boards but has not generated any
> response. I am working on modifing a chart using VB. I recorded the macro
> at first and got the following lines of code:
>
> ActiveChart.SeriesCollection(2).Points(1).DataLabel.Select
> Selection.AutoScaleFont = True
> With Selection.Font
> .Name = "Arial"
> .FontStyle = "Bold"
> .Size = 10
> .ColorIndex = 2
> .Background = xlTransparent
> End With
> With Selection
> .Position = xlLabelPositionInsideBase
> End With
>
> When I try to rerun this code without any modification, I get the following
> error:
>
> Select method of DataLabels class failed.
>
> I looked on a few boards and modified the code to look like this:
>
> ActiveChart.SeriesCollection (1)
> .HasDataLabels = True
> .ApplyDataLabels Type:=xlValue
> Selection.AutoScaleFont = True
> With .DataLabels.Font
> .Name = "Arial"
> .FontStyle = "Bold"
> .Size = 10
> .ColorIndex = 2
> End With
> With .DataLabels
> .Position = xlLabelInsideBase
> End With
>
> When i run this code, I get this error:
>
> Invalid or unqualified reference
>
> Is there some reference library that I need to select or something I need to
> change in the code? Any ideas would be greatly appreciated.
>
> Kristin
>

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      29th Oct 2007
Kristin,
You needed another With statement so the labels would know
to which series they belonged.
The Position constant was incorrect.
AutoScaling belongs to the Labels not the Series.
'--
With ActiveChart.SeriesCollection(1)
.HasDataLabels = True
.ApplyDataLabels Type:=xlValue
With .DataLabels.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 2
End With
With .DataLabels
.AutoScaleFont = True
.Position = xlLabelPositionInsideBase
End With
End With
'--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Check out the Chart Data Labels add-in)



"Kristin"
wrote in message
I am writing a macro to create the chart from scratch and place the data
labels on the chart. The rest of the code works great. It hangs up where it
is supposed to add the data labels and do some formatting to the label. And
I am using XL 03.



"Jim Cone" wrote:
> Kristin,
> What are you trying to do?
> Does the chart have data labels and you want to change something about them?
> Are you trying to add data labels?
> Something else?
> What version of XL are you using?
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)


 
Reply With Quote
 
=?Utf-8?B?S3Jpc3Rpbg==?=
Guest
Posts: n/a
 
      30th Oct 2007
Thanks. That did the trick.

"Jim Cone" wrote:

> Kristin,
> You needed another With statement so the labels would know
> to which series they belonged.
> The Position constant was incorrect.
> AutoScaling belongs to the Labels not the Series.
> '--
> With ActiveChart.SeriesCollection(1)
> .HasDataLabels = True
> .ApplyDataLabels Type:=xlValue
> With .DataLabels.Font
> .Name = "Arial"
> .FontStyle = "Bold"
> .Size = 10
> .ColorIndex = 2
> End With
> With .DataLabels
> .AutoScaleFont = True
> .Position = xlLabelPositionInsideBase
> End With
> End With
> '--
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Check out the Chart Data Labels add-in)
>
>
>
> "Kristin"
> wrote in message
> I am writing a macro to create the chart from scratch and place the data
> labels on the chart. The rest of the code works great. It hangs up where it
> is supposed to add the data labels and do some formatting to the label. And
> I am using XL 03.
>
>
>
> "Jim Cone" wrote:
> > Kristin,
> > What are you trying to do?
> > Does the chart have data labels and you want to change something about them?
> > Are you trying to add data labels?
> > Something else?
> > What version of XL are you using?
> > --
> > Jim Cone
> > San Francisco, USA
> > http://www.realezsites.com/bus/primitivesoftware
> > (Excel Add-ins / Excel Programming)

>
>

 
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
Macro to add labels to data points in an xy scatter chart =?Utf-8?B?U2NvdHQgV2FnbmVy?= Microsoft Excel Charting 4 12th Jun 2009 10:15 PM
Data Labels- POssible to show data value and data label together? kippers Microsoft Excel Charting 1 1st Apr 2009 01:33 PM
macro to apply data labels to points of an xy scatter graph juliadailey Microsoft Excel Charting 0 12th Sep 2008 10:55 AM
Macro Auto-update of data labels brandon.j.rapp@gmail.com Microsoft Excel Worksheet Functions 0 7th Aug 2007 04:17 PM
Data Labels/Axis Labels Jane Microsoft Excel Charting 5 31st Mar 2004 04:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:34 AM.