Macro to Remove Legend from ALL Charts

JonesyUK

Board Regular
Joined
Oct 11, 2005
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hi Experts, I have 200 charts on a single Excel worksheet named ("Charts").

Each Chart has a legend at the bottom of the chart("Actual").

I need to remove this legend from ALL of the charts please. At the moment, I am doing this manually, (Click on Chart), (Click "Layout"), (Click "Legend"), (Click "None").

This is going to take forever! Please help...

Thanks,
CJ
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Code:
[COLOR="Blue"]Sub[/COLOR] DeleteAllCharts()

    [COLOR="Blue"]Dim[/COLOR] co [COLOR="Blue"]As[/COLOR] ChartObject
    
    Application.ScreenUpdating = [COLOR="Blue"]False[/COLOR]
    
    [COLOR="Blue"]For[/COLOR] [COLOR="Blue"]Each[/COLOR] co [COLOR="Blue"]In[/COLOR] Sheets("Charts").ChartObjects
        co.Chart.HasLegend = [COLOR="Blue"]False[/COLOR]
    [COLOR="Blue"]Next[/COLOR]

[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Last edited:
Upvote 0
Code:
Sub Remove_Legend()
Dim i As Integer
Application.ScreenUpdating = False
For i = 1 To ActiveSheet.ChartObjects.Count
    Application.StatusBar = "Updating chart " & i & " of " & ActiveSheet.ChartObjects.Count
    ActiveSheet.ChartObjects(i).Chart.HasLegend = False
Next i
With Application
    .StatusBar = False
    .ScreenUpdating = False
End With
End Sub
 
Upvote 0
Many thanks for both suggestions... worked perfectly....!
 
Upvote 0
Hi Again,

How do I change all the charts from line charts to bar charts with no border (i.e. bars have no border).

Thanks!
CJ
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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