5

Excel allows the user to set the size of the hole in a doughnut chart between 0% and 90%. In VBA, the accepted range is 10% to 90%.

I can record a macro that produces this code:

ActiveChart.ChartGroups(1).DoughnutHoleSize = 0

However, it raises an error if I try to re-run it. Is there another way to set the DoughnutHoleSize to a value less than 10 in VBA? See the image below for the kind of plot I am trying to build.

Combo dounghnut and scatter chart

Community
  • 1
  • 1
Justin Moser
  • 2,005
  • 3
  • 22
  • 28
  • *it raises an error if I try to re-run it* - which error? Are you sure you have a chart object actually active when you re-run it? If so, is it the chart you think it is? Try assigning parentage and referencing the chart explicity instead of using `ActiveChart`? – Scott Holtzman Nov 14 '16 at 18:57
  • It errors on the '.DoughnutHoleSize = 0'. I have checked that the DoughnutHoleSize property exists and the above code works as expected with values between 10 and 90. It only errors when I try to use a value less than 10. The ActiveChart/ChartGroups(1)/etc. is not causing any errors. – Justin Moser Nov 14 '16 at 19:02
  • 3
    Things that make you go hmmm.... Wouldn't a doughnut hole chart with a hole size of 0 be a pie chart? – xQbert Nov 14 '16 at 19:08
  • 1
    @xQbert, I should explain why I am using a doughnut chart! I am creating a polar plot and I am using the dounghnut chart for the gridlines. I don't know of a way to do the gridlines with the pie chart. – Justin Moser Nov 14 '16 at 19:20
  • Consider using a Radar chart instead? http://best-excel-tutorial.com/56-charts/262-polar-chart or a stack example: http://stackoverflow.com/questions/32725844/add-radial-lines-to-radar-chart – xQbert Nov 14 '16 at 19:26

1 Answers1

0

I can't see any way of setting the DoughnutHoleSize to zero through VBA.

However, you can change just the inner-most series to a pie-chart. This will fill in the middle and keep the outer-series as Doughnuts.

ActiveChart.FullSeriesCollection(1).ChartType = xlPie

Michael
  • 4,563
  • 2
  • 11
  • 25