Salut,
Avant toutes choses, merci de placer ton code entre balises c/c++, cela permettra une meilleure lisibilité et ajoutera les numéros de lignes ...
Dans ton code, ajoute et/ou modifie les lignes :
Code :
- Option Explicit
- Public Sub LabelAndColor()
- Dim wb As Workbook
- Dim wsData As Worksheet, wsChart As Worksheet
- Dim objChart As ChartObject
- Dim i As Long
- Set wb = ActiveWorkbook
- Set wsData = wb.Worksheets("données indiv pour graph" )
- Set wsChart = wb.Worksheets("Graphiques" )
- -------> For z = 1 to wsChart.ChartObjects.Count
- Set objChart = wsChart.ChartObjects(1) ---- devient -----> Set objChart = wsChart.ChartObjects(z)
-
- With objChart.Chart.SeriesCollection(1)
- .ApplyDataLabels Type:=xlDataLabelsShowLabel
- For i = 1 To .Points.Count
- With .Points(i)
- .DataLabel.Text = wsData.Cells(i + 2, 1)
- .DataLabel.Font.Size = 9
- .MarkerBackgroundColorIndex = _
- wsData.Cells(i + 2, 1).Interior.ColorIndex
- End With
- Next i
- End With
- Set objChart = Nothing
- -------> Next z
- Set wsChart = Nothing: Set wsData = Nothing
- End Sub
|
En clair, fait une boucle sur tous les objets ChartObjects de ta feuille ...
Message édité par Chelmi18 le 07-07-2016 à 08:51:09