Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old January 22nd 09, 11:19 AM posted to microsoft.public.excel.misc
external usenet poster
 
First recorded activity by ExcelBanter: Oct 2007
Posts: 50
Default macro to label last point for selected series only

i have the lastpointlabel macro from jon pielter for the active chart, it is
possible also to label last point to a selected series only. appreciate any
help.

  #2   Report Post  
Old January 22nd 09, 11:56 AM posted to microsoft.public.excel.misc
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 2,489
Default macro to label last point for selected series only

Hi,

Try this revision to Jon's code.

'--------------
Sub LastPointLabel()
Dim mySrs As Series
Dim iPts As Long
Dim bLabeled As Boolean

If ActiveChart Is Nothing Then
MsgBox "Select a chart and try again.", vbExclamation, "No Chart
Selected"
Else
If TypeOf Selection Is Series Then
bLabeled = False
Set mySrs = Selection
With mySrs
For iPts = .Points.Count To 1 Step -1
If bLabeled Then
' handle error if point isn't plotted
On Error Resume Next
' remove existing label if it's not the last point
mySrs.Points(iPts).HasDataLabel = False
On Error GoTo 0
Else
' handle error if point isn't plotted
On Error Resume Next
' add label
mySrs.Points(iPts).ApplyDataLabels _
ShowSeriesName:=True, _
AutoText:=True, LegendKey:=False
bLabeled = (Err.Number = 0)
On Error GoTo 0
End If
Next
End With
Else
For Each mySrs In ActiveChart.SeriesCollection
bLabeled = False
With mySrs
For iPts = .Points.Count To 1 Step -1
If bLabeled Then
' handle error if point isn't plotted
On Error Resume Next
' remove existing label if it's not the last
point
mySrs.Points(iPts).HasDataLabel = False
On Error GoTo 0
Else
' handle error if point isn't plotted
On Error Resume Next
' add label
mySrs.Points(iPts).ApplyDataLabels _
ShowSeriesName:=True, _
AutoText:=True,
LegendKey:=False
bLabeled = (Err.Number = 0)
On Error GoTo 0
End If
Next
End With
Next
End If
End If
End Sub
'---------------------------

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"EricBB" wrote in message
...
i have the lastpointlabel macro from jon pielter for the active chart, it
is
possible also to label last point to a selected series only. appreciate
any
help.




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
how do I put a text label on a point in an XY scatter Paul Charts and Charting in Excel 1 October 4th 08 01:54 PM
Series 1 Point "0" Data Label Keyrookie Charts and Charting in Excel 2 November 15th 07 02:06 PM
How do I add a unique data label to each point in a bubble chart? Bryan Charts and Charting in Excel 1 May 20th 06 01:29 AM
How do I type in a tab label and get that tab to be selected? hotdoxy Excel Discussion (Misc queries) 1 May 23rd 05 09:56 PM
scatter plot & label for a data point shabnam Charts and Charting in Excel 3 April 11th 05 06:37 PM


All times are GMT +1. The time now is 01:28 AM.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017