How to Set an Excel Chart Legend to the Top by Default
Question details
The user wants to know how to automatically position chart legends at the top of their Excel charts by default.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Creating or formatting multiple charts and wanting a consistent legend placement at the top without manual adjustment.
- Observed behavior
- Excel places legends in a default position based on the chart type and does not offer a global setting to change this default behavior to the top.
Since Excel does not have a built-in toggle for default legend positions, you will need to use a VBA macro. Ensure you have the Developer tab enabled in your Excel ribbon to access the VBA editor.
Use a VBA Macro to Move All Chart Legends to the Top
Apply a VBA script to automatically reposition the legends of all existing charts on your active worksheet to the top.
Because Excel lacks a native setting to change the default legend position for new charts, the most efficient workaround is to create your charts first, then run a macro that updates all of them at once.
Press ALT + F11 on your keyboard to open the Microsoft Visual Basic for Applications window.
Click on Insert in the top menu, then select Module to create a blank script window.
Copy and paste the following code into the module: Sub SetLegendsToTop() Dim chtObj As ChartObject For Each chtObj In ActiveSheet.ChartObjects chtObj.Chart.HasLegend = True chtObj.Chart.Legend.Position = xlLegendPositionTop Next chtObj End Sub
Close the VBA editor, return to your worksheet, press ALT + F8, select 'SetLegendsToTop', and click Run. All chart legends on the active sheet will instantly move to the top.

Manage Charts and Data Easily with WPS Spreadsheet
WPS Spreadsheet offers a highly intuitive interface for customizing charts. While default legend positions require macros across most spreadsheet software, WPS Office provides seamless macro support and easy one-click chart layout options to position your legends exactly where you want them.
- 1. Open your workbook in WPS Spreadsheet: Launch WPS Office and open your existing spreadsheet containing the charts.
- 2. Select your chart: Click on the chart you want to modify to reveal the Chart Tools menu.
- 3. Adjust the legend position: Click the 'Chart Elements' button next to the chart, hover over 'Legend', and select 'Top' to instantly move it.
- 4. Use Macros for bulk edits: If you have many charts, you can run the exact same VBA macro in WPS Spreadsheet by accessing the Developer tab and running the script.

Frequently Asked Questions
Can I save a chart template with the legend at the top?
Yes. Format a single chart with the legend at the top, right-click the chart, and select 'Save as Template'. You can then apply this template when creating future charts to keep the legend at the top automatically.
Why doesn't Excel have a default legend position setting?
Excel relies on predefined chart layouts and themes. The default legend position is determined by the specific chart type and layout chosen, rather than a global user preference setting.
Does this VBA macro affect charts on other worksheets?
The provided macro only affects the active worksheet (the one you are currently viewing). To apply it to the entire workbook, the VBA code must be modified to loop through all worksheets.




