Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Code to move DataLables to top of Chart

I am creating a series of column charts, and I would like to move all the
data labels in a series to the top of the chart (above the column and evenly
spaced)

The VBA code to do so for any individual point in the series is:

' ActiveChart.SeriesCollection(3).Points(1).DataLabe l.Select
' Selection.Top = 52

I would like to automate this to do it for every point in the
seriescollection, and have tried the following:

Sub LabelsToTop()

For Each Points In ActiveChart.SeriesCollection(4)
DatalLabel.Select
Selection.Top = 52
Next

End Sub

But get an Object Variable Error Messge. Does anyone know the correct
sytax ? I am using Excel 2000 with SP-3

Thanks

Frank


  #2   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 235
Default VBA Code to move DataLables to top of Chart

Consider revising your For-Next statement to the following (also note that
this procedure should perform more efficiently as it does not use a "Select"
statement):

Sub AlignDataLabels()
On Error Resume Next
Dim Cnt As Long
Set Srs = ActiveChart.SeriesCollection(3)
With Srs
For Cnt = 1 To .Points.Count
Srs.Points(Cnt).DataLabel.Top = 52
Next
End With
End Sub

--
John Mansfield
http://cellmatrix.net


"Frank Hayes" wrote:

I am creating a series of column charts, and I would like to move all the
data labels in a series to the top of the chart (above the column and evenly
spaced)

The VBA code to do so for any individual point in the series is:

' ActiveChart.SeriesCollection(3).Points(1).DataLabe l.Select
' Selection.Top = 52

I would like to automate this to do it for every point in the
seriescollection, and have tried the following:

Sub LabelsToTop()

For Each Points In ActiveChart.SeriesCollection(4)
DatalLabel.Select
Selection.Top = 52
Next

End Sub

But get an Object Variable Error Messge. Does anyone know the correct
sytax ? I am using Excel 2000 with SP-3

Thanks

Frank



  #3   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default VBA Code to move DataLables to top of Chart

Frank,
Try this...

Sub MoveLabelsUp()
Dim objPt As Point
For Each objPt In ActiveChart.SeriesCollection(3).Points
objPt.DataLabel.Top = 52
Next
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Chart Data Labels Excel Add-in)


"Frank Hayes"
wrote in message
I am creating a series of column charts, and I would like to move all the
data labels in a series to the top of the chart (above the column and evenly
spaced)

The VBA code to do so for any individual point in the series is:

' ActiveChart.SeriesCollection(3).Points(1).DataLabe l.Select
' Selection.Top = 52

I would like to automate this to do it for every point in the
seriescollection, and have tried the following:

Sub LabelsToTop()

For Each Points In ActiveChart.SeriesCollection(4)
DatalLabel.Select
Selection.Top = 52
Next

End Sub

But get an Object Variable Error Messge. Does anyone know the correct
sytax ? I am using Excel 2000 with SP-3
Thanks
Frank


  #4   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Code to move DataLables to top of Chart

Perfect. Thank you.


"John Mansfield" wrote in message
...
Consider revising your For-Next statement to the following (also note that
this procedure should perform more efficiently as it does not use a
"Select"
statement):

Sub AlignDataLabels()
On Error Resume Next
Dim Cnt As Long
Set Srs = ActiveChart.SeriesCollection(3)
With Srs
For Cnt = 1 To .Points.Count
Srs.Points(Cnt).DataLabel.Top = 52
Next
End With
End Sub

--
John Mansfield
http://cellmatrix.net


"Frank Hayes" wrote:

I am creating a series of column charts, and I would like to move all the
data labels in a series to the top of the chart (above the column and
evenly
spaced)

The VBA code to do so for any individual point in the series is:

' ActiveChart.SeriesCollection(3).Points(1).DataLabe l.Select
' Selection.Top = 52

I would like to automate this to do it for every point in the
seriescollection, and have tried the following:

Sub LabelsToTop()

For Each Points In ActiveChart.SeriesCollection(4)
DatalLabel.Select
Selection.Top = 52
Next

End Sub

But get an Object Variable Error Messge. Does anyone know the correct
sytax ? I am using Excel 2000 with SP-3

Thanks

Frank





  #5   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Code to move DataLables to top of Chart

Thank you.

"Jim Cone" wrote in message
...
Frank,
Try this...

Sub MoveLabelsUp()
Dim objPt As Point
For Each objPt In ActiveChart.SeriesCollection(3).Points
objPt.DataLabel.Top = 52
Next
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Chart Data Labels Excel Add-in)


"Frank Hayes"
wrote in message
I am creating a series of column charts, and I would like to move all the
data labels in a series to the top of the chart (above the column and
evenly
spaced)

The VBA code to do so for any individual point in the series is:

' ActiveChart.SeriesCollection(3).Points(1).DataLabe l.Select
' Selection.Top = 52

I would like to automate this to do it for every point in the
seriescollection, and have tried the following:

Sub LabelsToTop()

For Each Points In ActiveChart.SeriesCollection(4)
DatalLabel.Select
Selection.Top = 52
Next

End Sub

But get an Object Variable Error Messge. Does anyone know the correct
sytax ? I am using Excel 2000 with SP-3
Thanks
Frank




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
Position DataLables on a pivot pie chart realative to their Points Aaron Charts and Charting in Excel 0 September 1st 07 07:12 PM
Code to Move Several Lines to Master Worksheet MGC Excel Discussion (Misc queries) 5 August 18th 07 01:48 PM
How to draw a line on a chart, and have it move with the chart? manxman Charts and Charting in Excel 5 September 27th 06 09:31 PM
How do i move a chart ExcelUser123 Charts and Charting in Excel 2 May 17th 06 09:28 AM
Pivot Table VBA code to move a row uclawarren Excel Discussion (Misc queries) 0 October 10th 05 08:49 PM


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