Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Run-Time Chart Only Displays Even DataLabels

Hello All,

I'm trying to programmatically add data labels to a chart that is also
created programmatically. I've used the following to go through the
SeriesCollection(iSeries) added elsewhere in the subroutine:

Dim ptsPoint As Points
Dim ptsCount As Integer
Dim iCountPoints As Integer
Set ptsPoint = chartMyChart.SeriesCollection(iSeries).Points
ptsCount = WorksheetFunction.CountA(Sheets("Results").Columns (1))
For iCountPoints = 1 To ptsCount
ptsPoint(iCountPoints).HasDataLabel = True
ptsPoint(iCountPoints).ApplyDataLabels Type:=xlDataLabelsShowValue
ptsPoint(iCountPoints).DataLabel.HorizontalAlignme nt = xlLeft
ptsPoint(iCountPoints).DataLabel.VerticalAlignment = xlTop
ptsPoint(iCountPoints).DataLabel.Position = xlLabelPositionBelow
ptsPoint(iCountPoints).DataLabel.Orientation = xlUpward
ptsPoint(iCountPoints).DataLabel.Font.Size = 6
ptsPoint(iCountPoints).DataLabel.Text =
Sheets("Results").Cells(iCountPoints, 1).Value
ptsPoint(iCountPoints).DataLabel.ShowValue = True
iCountPoints = iCountPoints + 1
Next

This works fine but the chart only shows the even data labels. So, if
there were five points based on the values in column A of the Results
sheet that read:

Monday
Tuesday
Wednesday
Thursday
Friday

Only Monday, Wednesday and Friday would be shown on the chart itself.
I've tried reducing the font or just temporarily putting a "." instead
of the values in column A (so the chart is less cluttered), but that
doesn't seem to make a difference. I've tried forcing it using the
..DataLabel.ShowValue = True, but that hasn't made any difference
either. Any advice?

Many thanks for any help you can offer.

Cheers,

Ross.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Run-Time Chart Only Displays Even DataLabels

Hi Ross,

I haven't tried your code but suggest you remove this line
iCountPoints = iCountPoints + 1

In passing you could probably apply DataLabels to the entire series in one
go with your formats, then loop the Datalabels applying your text up until
you get to ptsCount, then delete any further labels (if any).

Regards,
Peter T

"Rawce" wrote in message
ps.com...
Hello All,

I'm trying to programmatically add data labels to a chart that is also
created programmatically. I've used the following to go through the
SeriesCollection(iSeries) added elsewhere in the subroutine:

Dim ptsPoint As Points
Dim ptsCount As Integer
Dim iCountPoints As Integer
Set ptsPoint = chartMyChart.SeriesCollection(iSeries).Points
ptsCount = WorksheetFunction.CountA(Sheets("Results").Columns (1))
For iCountPoints = 1 To ptsCount
ptsPoint(iCountPoints).HasDataLabel = True
ptsPoint(iCountPoints).ApplyDataLabels Type:=xlDataLabelsShowValue
ptsPoint(iCountPoints).DataLabel.HorizontalAlignme nt = xlLeft
ptsPoint(iCountPoints).DataLabel.VerticalAlignment = xlTop
ptsPoint(iCountPoints).DataLabel.Position = xlLabelPositionBelow
ptsPoint(iCountPoints).DataLabel.Orientation = xlUpward
ptsPoint(iCountPoints).DataLabel.Font.Size = 6
ptsPoint(iCountPoints).DataLabel.Text =
Sheets("Results").Cells(iCountPoints, 1).Value
ptsPoint(iCountPoints).DataLabel.ShowValue = True
iCountPoints = iCountPoints + 1
Next

This works fine but the chart only shows the even data labels. So, if
there were five points based on the values in column A of the Results
sheet that read:

Monday
Tuesday
Wednesday
Thursday
Friday

Only Monday, Wednesday and Friday would be shown on the chart itself.
I've tried reducing the font or just temporarily putting a "." instead
of the values in column A (so the chart is less cluttered), but that
doesn't seem to make a difference. I've tried forcing it using the
.DataLabel.ShowValue = True, but that hasn't made any difference
either. Any advice?

Many thanks for any help you can offer.

Cheers,

Ross.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Run-Time Chart Only Displays Even DataLabels

Hah hah! I'm such a numpty. I'm getting my loops all messed up. You're
entirely right, the For is looping with the Next anyway, so I'm
actually double incrementing - hence the even labels applying only.
Sorry, I thought it was some quirk with Excel and how it plots charts,
not me being used to using Do Whiles!

Humble apologies and many thanks,

Ross.

Peter T wrote:
Hi Ross,

I haven't tried your code but suggest you remove this line
iCountPoints = iCountPoints + 1

In passing you could probably apply DataLabels to the entire series in one
go with your formats, then loop the Datalabels applying your text up until
you get to ptsCount, then delete any further labels (if any).

Regards,
Peter T

"Rawce" wrote in message
ps.com...
Hello All,

I'm trying to programmatically add data labels to a chart that is also
created programmatically. I've used the following to go through the
SeriesCollection(iSeries) added elsewhere in the subroutine:

Dim ptsPoint As Points
Dim ptsCount As Integer
Dim iCountPoints As Integer
Set ptsPoint = chartMyChart.SeriesCollection(iSeries).Points
ptsCount = WorksheetFunction.CountA(Sheets("Results").Columns (1))
For iCountPoints = 1 To ptsCount
ptsPoint(iCountPoints).HasDataLabel = True
ptsPoint(iCountPoints).ApplyDataLabels Type:=xlDataLabelsShowValue
ptsPoint(iCountPoints).DataLabel.HorizontalAlignme nt = xlLeft
ptsPoint(iCountPoints).DataLabel.VerticalAlignment = xlTop
ptsPoint(iCountPoints).DataLabel.Position = xlLabelPositionBelow
ptsPoint(iCountPoints).DataLabel.Orientation = xlUpward
ptsPoint(iCountPoints).DataLabel.Font.Size = 6
ptsPoint(iCountPoints).DataLabel.Text =
Sheets("Results").Cells(iCountPoints, 1).Value
ptsPoint(iCountPoints).DataLabel.ShowValue = True
iCountPoints = iCountPoints + 1
Next

This works fine but the chart only shows the even data labels. So, if
there were five points based on the values in column A of the Results
sheet that read:

Monday
Tuesday
Wednesday
Thursday
Friday

Only Monday, Wednesday and Friday would be shown on the chart itself.
I've tried reducing the font or just temporarily putting a "." instead
of the values in column A (so the chart is less cluttered), but that
doesn't seem to make a difference. I've tried forcing it using the
.DataLabel.ShowValue = True, but that hasn't made any difference
either. Any advice?

Many thanks for any help you can offer.

Cheers,

Ross.


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
Chart incorrectly displays time of day on x-axis SPH1967 Excel Discussion (Misc queries) 3 February 15th 09 06:16 PM
Chart Datalabels.Position Michael Singmin Excel Programming 4 November 12th 05 07:12 PM
Lock the chart but leave datalabels position editable Joy Charts and Charting in Excel 1 June 13th 05 08:21 PM
Be able to edit position of datalabels in a protected chart. Joy Excel Programming 2 June 13th 05 08:21 PM
Excel Chart Datalabels Sean Howard Excel Programming 6 April 20th 04 12:04 AM


All times are GMT +1. The time now is 10:17 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"