Remove legend where no data in the chart

bruty

Active Member
Joined
Jul 25, 2007
Messages
453
I have a doughnut chart that is showing the results for the current quarter next to a column chart which shows the results for the current quarter and previous 2. When there is no data for the current quarter, the doughnut chart does not appear (which is fine) but the legend is still there. This is fine for the column chart as there is normally data in at least one of the 3 quarters shown.

Is there any way to remove or suppress the legend in the doughnut chart when there is no data for the current quarter?

Please note that both charts are fed from the same data, which is a data table that cannot be changed.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
This code with the chart selected
ActiveChart.Legend.Delete
or this code with the appropriate chart name substituted for 'Chart 3' and with the sheet holding the chart properly referenced
ActiveSheet.ChartObjects("Chart 3").Chart.Legend.Delete

This code will add and position a legend:
ActiveSheet.ChartObjects("Chart 3").Chart.HasLegend = True
ActiveSheet.ChartObjects("Chart 3").Chart.Legend.Position = xlBottom
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top