ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic Data Labels (https://www.excelbanter.com/excel-programming/358358-re-dynamic-data-labels.html)

Martin Krastev[_2_]

Dynamic Data Labels
 
Hi

You can apply data labels to all series of all charts on the active sheet in
the following way:

Dim co As ChartObject
Dim ser As Series
For Each co In ActiveSheet.ChartObjects
For Each ser In co.Chart.SeriesCollection
ser.ApplyDataLabels xlDataLabelsShowLabel
Next ser
Next co

If you have defined your chart series correctly, the labels will be correct!

Hope that works!

"NicB." wrote:


All right,

I am building a scatter plot chart that I want be very interactive. I
have coded the workbook such that it allows the user to select which
data set(s) to view and to turn data labels on and off. In addition to
this, each series will have a name, but I want each specific data point
to have its own name that will change based upon values listed in
worksheet cells.

I have been able to accomplish all of the above, but now I want an easy
way to repeat this for all data sets and all data points. I am thinking
of a loop statement or a "for every x" type statement, but am not very
familiar with these. For example I need something like the first few
lines of the code below...

Sub Data_Labels()

'This doesn't work

Dim SeriesCollections As X
Dim Points As Y
For Every X and Y

'This does work

ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.SeriesCollection(1).Points(3).Select
With Selection
.HasDataLabel = True
.DataLabel.Text = Range("N20")
End With

End Sub

Thoughts?

Thank you,

NicB.


--
NicB.
------------------------------------------------------------------------
NicB.'s Profile: http://www.excelforum.com/member.php...o&userid=20639
View this thread: http://www.excelforum.com/showthread...hreadid=530997




All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com