Microsoft Office Tutorials and References
In Depth Information
7.4 Beispiel: Formatiertes Kreisdiagramm
Zunächst der Code:
Sub DiagrammKreis()
Dim CO As ChartObject
Dim CH As Chart
Dim i As Integer
Set CO = ThisWorkbook.Worksheets("Tabelle2"). _
ChartObjects.Add(200, 10, 400, 350)
Set CH = CO.Chart
' Diagrammtyp und Datenquelle
CH.ChartType = xlPie
CH.SetSourceData Range("A1:B13")
' Diagramm- und Zeichnungsfläche
CH.ChartArea.Interior.Color = vbCyan
CH.PlotArea.Interior.Color = vbYellow
' Titel
CH.HasTitle = True
CH.ChartTitle.Text = "Spanien 2004"
' Legende
CH.HasLegend = True
With CH.Legend
.Interior.Color = vbYellow
.Border.Color = vbBlue
.Border.Weight = xlThick
End With
'Datenpunkte
CH.SeriesCollection(1).Points(1). _
Interior.Color = vbWhite
Fori=1ToCH.SeriesCollection(1).Points.Count
If Cells(i + 1, 2) > 500000 Then
With CH.SeriesCollection(1).Points(i)
.ApplyDataLabels _
xlDataLabelsShowLabelAndPercent
.DataLabel.NumberFormat = "0.00%"
End With
End If
Next i
End Sub
Search JabSto ::




Custom Search