Chartspace et diagramme camembert

Arnault30

XLDnaute Nouveau
Bonjour,

J'ai quelques difficultés à intégrer un diagramme camembert dans ma userforme. Voici le code... Si vous avez des idées suggestions je suis preneur:

Code:
   Dim xValues As Variant, yValues1 As Variant
    xValues = Array("Beverages", "Condiments", "Confections", _
                    "Dairy Products", "Grains & Cereals", _
                    "Meat & Poultry", "Produce", "Seafood")
    yValues1 = Array(104737, 50952, 78128, 117797, 52902, 80160, 47491, _
                     62435)
                     

'Create a new exploded pie chart from the query
    Set oPieChart = ChartSpace1.Charts.Add
    With oPieChart
        .Type = chChartTypePie

        [COLOR="Orange"]'.SetData chDimCategories, 0, xValues[/COLOR]
        '.SetData chDimValues, 0, yValues1
        .SeriesCollection(0).Explosion = 20
        
        'Add a legend to the bottom of the pie chart
        .HasLegend = True
        .Legend.Position = chLegendPositionBottom
        
        'Add a title to the chart
        .HasTitle = True
        .Title.Caption = "Sales by Category for 1995"
        .Title.Font.Bold = True
        .Title.Font.Size = 11
        
        'Make the chart width 50% the size of the bar chart's width
        .WidthRatio = 50
        
        'Show data labels on the slices as percentages
        With .SeriesCollection(0).DataLabelsCollection.Add
            .HasValue = False
            .HasPercentage = True
            .Font.Size = 8
            .Interior.Color = RGB(255, 255, 255)
        End With
        
    End With


J'ai repris un bout de code du site Microsoft... l'erreur est la suivante:

"Index de sources de données non valides"

Merci beaucoup :)