XL 2010 Graphique et mise en forme étiquettes de données (VBA)

Lougral

XLDnaute Nouveau
Bonjour à tous,
Voici le problème que je rencontre : J'essaie de placer par une macro des étiquettes de donnée qu sont issues d'une autre plage que la plage de données. Mon graphique est crée avec un Tableau parfois filtré. Jusque là tout va bien. Par contre je n'arrive pas à mettre en forme les étiquettes (une d'entre elle doit être en %).
Je joint un fichier avec mon message.
Merci d'avance pour votre aide.
Francis
 

Pièces jointes

  • essai etiquettes.xlsm
    24.5 KB · Affichages: 51

Lougral

XLDnaute Nouveau
Merci des pistes que tu m'as fournies. Cela m'as permis de résoudre mon problème.
je te joins le code utilisé :
VB:
Sub FiltreGraph()
  Dim Graph As ChartObject
  Dim Sery As Series
  Dim i As Integer
  Dim p As Integer
    Worksheets("Resultat2").Unprotect Password:=""

    ActiveSheet.ListObjects("Tableau1").Range.AutoFilter Field:=2, Criteria1:= _
            "<>pasaffiche", Operator:=xlAnd
    Set Graph = Worksheets("Resultat2").ChartObjects("Graphique 17")
    Set Sery = Graph.Chart.SeriesCollection(1)
    Sery.ApplyDataLabels xlDataLabelsShowNone
    Sery.ApplyDataLabels xlDataLabelsShowValue
      If IsNumeric(Range("AB97").Value) Then
            With Sery
              For i = 1 To .Points.Count
                .Points(i).DataLabel.Text = Format(Range("AC" & 91 + i).Value, "0.00 €")
              Next i
              .Points(3).DataLabel.Text = Format(Range("AC94").Value, "0%")
            End With
          
        Else
            With Sery
                .Points(1).DataLabel.Text = Format(Range("AC92").Value, "0.00 €")
                .Points(2).DataLabel.Text = Format(Range("AC93").Value, "0.00 €")
                .Points(3).DataLabel.Text = Format(Range("AC94"), "0%")
                .Points(4).DataLabel.Text = Format(Range("AC95").Value, "0.00 €")
                .Points(5).DataLabel.Text = Format(Range("AC96").Value, "0.00 €")
                .Points(6).DataLabel.Text = Format(Range("AC98").Value, "0.00 €")
                .Points(7).DataLabel.Text = Format(Range("AC99").Value, "0.00 €")
                .Points(8).DataLabel.Text = Format(Range("AC100").Value, "0.00 €")
                .Points(9).DataLabel.Text = Format(Range("AC101").Value, "0.00 €")
               
            End With
           
      End If
              For p = 1 To Sery.Points.Count
                Sery.Points(p).DataLabel.Position = xlLabelPositionCenter
                Sery.DataLabels.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 255, 255)
                Sery.DataLabels.Format.TextFrame2.TextRange.Font.Bold = True
             
              Next p
        Worksheets("Resultat2").Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True

             
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 109
Messages
2 085 386
Membres
102 880
dernier inscrit
ADEL N