...but I want my doughnut to be full sized. As I want to move the title to the center of the doughnut, I don't need the top margin, which is added, it seems, through Chart.HasTitle = True. How can I work around this?
Examplary code
Sub createChart()
If ActiveSheet.ChartObjects.Count > 0 Then ActiveSheet.ChartObjects.Delete
Dim chrt As ChartObject
Dim dataRng As Range
Dim lft As Integer
lft = ActiveSheet.Range("D2").Left
Dim wdth As Integer
wdth = 500
Dim hgt As Integer
hgt = 300
Dim tp As Integer
tp = ActiveSheet.Range("D2").Top
Set chrt = ActiveSheet.ChartObjects.Add(Left:=lft, Width:=wdth, Height:=hgt, Top:=tp)
Dim i As Integer
For i = 1 To 10
ActiveSheet.Cells(i, 1).Value = "A" & i
With ActiveSheet.Cells(i, 2)
.Value = i / 55
.NumberFormat = "0.00%"
End With
Next i
Set dataRng = Range("A1:B10")
With chrt.Chart
.ChartType = xlDoughnut
.SetSourceData Source:=dataRng
' comment out from here
.HasTitle = True
With .ChartTitle
.Text = "Test"
.Top = hgt / 2
.Left = wdth / 2 - 20
End With
' to here
.HasLegend = False
End With
End Sub