Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
Here's macro for labelling XY charts.
but it only works for the the first series (you can reorder the series) and the labels have to be in the column (the data have to be in colums), to the left of the X-axis. but it works in 007 http://support.microsoft.com/kb/213750 Sub AttachLabelsToPoints() 'Dimension variables. Dim Counter As Integer, ChartName As String, xVals As String ' Disable screen updating while the subroutine is run. Application.ScreenUpdating = False 'Store the formula for the first series in "xVals". xVals = ActiveChart.SeriesCollection(1).Formula 'Extract the range for the data from xVals. xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, _ Mid(Left(xVals, InStr(xVals, "!") - 1), 9))) xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1) Do While Left(xVals, 1) = "," xVals = Mid(xVals, 2) Loop 'Attach a label to each data point in the chart. For Counter = 1 To Range(xVals).Cells.Count ActiveChart.SeriesCollection(1).Points(Counter).Ha sDataLabel = _ True ActiveChart.SeriesCollection(1).Points(Counter).Da taLabel.Text = _ Range(xVals).Cells(Counter, 1).Offset(0, -1).Value Next Counter End Sub |
#2
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
Ever try one of these?
Rob Bovey's Chart Labeler, http://appspro.com John Walkenbach's Chart Tools, http://j-walk.com - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions http://PeltierTech.com _______ "Gklass" wrote in message oups.com... Here's macro for labelling XY charts. but it only works for the the first series (you can reorder the series) and the labels have to be in the column (the data have to be in colums), to the left of the X-axis. but it works in 007 http://support.microsoft.com/kb/213750 Sub AttachLabelsToPoints() 'Dimension variables. Dim Counter As Integer, ChartName As String, xVals As String ' Disable screen updating while the subroutine is run. Application.ScreenUpdating = False 'Store the formula for the first series in "xVals". xVals = ActiveChart.SeriesCollection(1).Formula 'Extract the range for the data from xVals. xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, _ Mid(Left(xVals, InStr(xVals, "!") - 1), 9))) xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1) Do While Left(xVals, 1) = "," xVals = Mid(xVals, 2) Loop 'Attach a label to each data point in the chart. For Counter = 1 To Range(xVals).Cells.Count ActiveChart.SeriesCollection(1).Points(Counter).Ha sDataLabel = _ True ActiveChart.SeriesCollection(1).Points(Counter).Da taLabel.Text = _ Range(xVals).Cells(Counter, 1).Offset(0, -1).Value Next Counter End Sub |
#3
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
JOn:
Bovey's won't run in 007 Walkenb's might run but it doesn't appear on any menu. On Feb 4, 5:28 pm, "Jon Peltier" wrote: Ever try one of these? Rob Bovey's Chart Labeler,http://appspro.com John Walkenbach's Chart Tools,http://j-walk.com - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutionshttp://PeltierTech.com _______ "Gklass" wrote in message oups.com... Here's macro for labelling XY charts. but it only works for the the first series (you can reorder the series) and the labels have to be in the column (the data have to be in colums), to the left of the X-axis. but it works in 007 http://support.microsoft.com/kb/213750 Sub AttachLabelsToPoints() 'Dimension variables. Dim Counter As Integer, ChartName As String, xVals As String ' Disable screen updating while the subroutine is run. Application.ScreenUpdating = False 'Store the formula for the first series in "xVals". xVals = ActiveChart.SeriesCollection(1).Formula 'Extract the range for the data from xVals. xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, _ Mid(Left(xVals, InStr(xVals, "!") - 1), 9))) xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1) Do While Left(xVals, 1) = "," xVals = Mid(xVals, 2) Loop 'Attach a label to each data point in the chart. For Counter = 1 To Range(xVals).Cells.Count ActiveChart.SeriesCollection(1).Points(Counter).Ha sDataLabel = _ True ActiveChart.SeriesCollection(1).Points(Counter).Da taLabel.Text = _ Range(xVals).Cells(Counter, 1).Offset(0, -1).Value Next Counter End Sub |
#4
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
OK I found it!!!
on the add ins thing On Feb 4, 5:28 pm, "Jon Peltier" wrote: Ever try one of these? Rob Bovey's Chart Labeler,http://appspro.com John Walkenbach's Chart Tools,http://j-walk.com - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutionshttp://PeltierTech.com _______ "Gklass" wrote in message oups.com... Here's macro for labelling XY charts. but it only works for the the first series (you can reorder the series) and the labels have to be in the column (the data have to be in colums), to the left of the X-axis. but it works in 007 http://support.microsoft.com/kb/213750 Sub AttachLabelsToPoints() 'Dimension variables. Dim Counter As Integer, ChartName As String, xVals As String ' Disable screen updating while the subroutine is run. Application.ScreenUpdating = False 'Store the formula for the first series in "xVals". xVals = ActiveChart.SeriesCollection(1).Formula 'Extract the range for the data from xVals. xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, _ Mid(Left(xVals, InStr(xVals, "!") - 1), 9))) xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1) Do While Left(xVals, 1) = "," xVals = Mid(xVals, 2) Loop 'Attach a label to each data point in the chart. For Counter = 1 To Range(xVals).Cells.Count ActiveChart.SeriesCollection(1).Points(Counter).Ha sDataLabel = _ True ActiveChart.SeriesCollection(1).Points(Counter).Da taLabel.Text = _ Range(xVals).Cells(Counter, 1).Offset(0, -1).Value Next Counter End Sub |
#5
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
To extend this to any series, use the appropriate index wherever this
occurs: SeriesCollection(1) or change the reference point so that you select a series and run a macro, and change ActiveChart.SeriesCollection(1) to Selection Put this up front to bail out if no series is selected: If TypeName(Selection) < "Series" Then Exit Sub - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions http://PeltierTech.com _______ "Gklass" wrote in message oups.com... Here's macro for labelling XY charts. but it only works for the the first series (you can reorder the series) and the labels have to be in the column (the data have to be in colums), to the left of the X-axis. but it works in 007 http://support.microsoft.com/kb/213750 Sub AttachLabelsToPoints() 'Dimension variables. Dim Counter As Integer, ChartName As String, xVals As String ' Disable screen updating while the subroutine is run. Application.ScreenUpdating = False 'Store the formula for the first series in "xVals". xVals = ActiveChart.SeriesCollection(1).Formula 'Extract the range for the data from xVals. xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, _ Mid(Left(xVals, InStr(xVals, "!") - 1), 9))) xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1) Do While Left(xVals, 1) = "," xVals = Mid(xVals, 2) Loop 'Attach a label to each data point in the chart. For Counter = 1 To Range(xVals).Cells.Count ActiveChart.SeriesCollection(1).Points(Counter).Ha sDataLabel = _ True ActiveChart.SeriesCollection(1).Points(Counter).Da taLabel.Text = _ Range(xVals).Cells(Counter, 1).Offset(0, -1).Value Next Counter End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VB Macro to Create a Chart | Excel Discussion (Misc queries) | |||
Setting up Macro to create pie chart. | Charts and Charting in Excel | |||
text label in x-axis (scatter chart) | Charts and Charting in Excel | |||
How do I print comments on a chart? | Charts and Charting in Excel | |||
Macro to change Chart Range when inserting a column | Charts and Charting in Excel |