Charts are an excellent visualization tool, which is why we often end up having one too many in our worksheets.
Sometimes we might even end up having multiple copies of the same chart, thus requiring us to delete some of them.
This tutorial is going to be all about deleting charts (not creating them) for a change. We will look at how to delete charts in different cases
Manually Deleting a Single Chart in Excel
To delete a single chart from your sheet, simply click on the edge of the chart and press the Delete key on your keyboard.
Alternatively, you could select the chart, and navigate to Home-> Editing group-> Clear-> Clear All
Using the Navigation Pane (Microsoft 365 Only)
If you’re using Excel in Microsoft 365, you can use the Navigation option to see all the charts and objects you can in the workbook.
You can also easily select any chart you want to delete, and then hit the delete button.
Below are the steps to do this:
- Click the View tab
- In the Show group, click on Navigaton. This will open the Navigation pane on the right
- Click on the expand icon for the sheet that has the chart that you want to delete
- Right-click on the chart
- Click on Delete
The above steps would delete the selected chart.
If you only want to delete one single chart from the worksheet, this may look like a tedious method. in that case, you’re better off simply selecting the chart and deleting (as covered above).
The benefit of using navigation is that it shows you all the different sheets, charts, tables in one single pane. So if you want to delete multiple charts, or rename or hide them, then using this method would be useful.
Using VBA to Delete a Single Chart
If you have a lot of charts and prefer using VBA to individually select and delete charts, you can get this done with just a few lines of code.
If you prefer using VBA to delete individual charts, you can do so using the following code:
Dim chartName As Variant
chartName = InputBox(“Which chart would you like to delete”)
If MsgBox(“Are you sure you want to delete this chart?”, vbYesNo, “Confirm Deletion”) = vbYes Then
The above code will display an input box, letting you enter the name of the chart that you want to delete.
Once you enter the name of the chart, and confirm that you are sure you want to delete it, the code will delete the chart for you.
Tip: You will find the name of the chart to the left side of the formula bar when you select the chart.
To use the above code, follow the steps shown below:
- Navigate to Developer->Visual basic
- This opens your VBA window. Navigate to Insert->Module
- Copy and paste the above code into the module window
Your macro is now ready to run.
To run this macro, return to your Excel window and follow the steps shown below:
- Navigate to Developer->Macros
- This opens the Macro dialog box. Select the name of your module, which, in this case, is DeleteSingleChart.
- Click Run
- You should see an input box asking you to enter the name of the chart that you want to delete.
- Type in the name of the chart and press OK.
- You will then be asked to confirm if you’re sure you want to delete the chart.
- Click Yes.
You will now find your specified chart deleted.
How to Delete only the Content from your Chart
If you want to simply delete some content from the chart, like a chart title or legend, then deleting the whole chart does not make much sense.
After all, why go through the entire process of rebuilding your chart from scratch right?
To remove any content from your chart, simply click on the content that you want to remove and again press the Delete key on your keyboard.
This will retain the rest of the chart and only get rid of the particular content that you selected.
How to Delete a Chart Sheet
Charts in Excel can either be embedded in a regular worksheet or they can be in their own chart sheets.
A chart sheet is a separate sheet in your workbook containing a chart.
The chart sheet looks similar to any other worksheet in your workbook and even has a separate tab for it at the bottom of your Excel window.
The only difference is that the chart sheet only contains a chart, and no cells and grids.
Deleting a chart sheet is similar to deleting any regular Excel sheet. All you need to do is right-click on the chart sheet’s tab and select ‘Delete’ from the context menu that appears.
You will be asked to confirm that you want to permanently delete the chart sheet. Click the Delete button.
How to Delete all Charts in the Active Sheet
Let us now look at a case where you want to remove all the charts from a particular sheet. The solution for this is easy. Simply use the following code.:
We already explained in this tutorial how to enter code into the Visual Basic window.
To run the code, navigate to Developer->Macros, and this time, select the macro named DeleteAllChartsOnSheet.
You will find all the charts on your active sheet deleted in one go.
Note that the deletions performed by your VBA code cannot be reversed. So, once you delete all the charts from a sheet, you will not be able to get them back.
To protect against accidental deletions, you can add a confirmation message box as part of your code, as follows:
If MsgBox(“Are you sure you want to delete all charts in this sheet?”, vbYesNo, “Confirm Deletion”) = vbYes Then
Now you will see a message box asking you whether you are sure you want to delete all these charts.
Once you confirm by clicking Yes, the macro will delete all charts in your sheet.
How to Delete all Charts in the Active Workbook
Let us now look at the final case, where you want to remove all charts from an entire workbook, not just a single worksheet.
For this you can use the following vba code:
Dim sh As Object
For Each sh In ActiveWorkbook.Sheets
The above code goes through each sheet in the active workbook and deletes all the charts in them.
Follow the same steps as shown in the previous section to insert and run the VBA code. Once you run the code, all charts in your current workbook will get deleted.
If you want to add a confirmation message box before deleting all the sheets, you can use the following version of the code instead:
Dim sh As Object
If MsgBox(“Are you sure you want to delete all charts in the workbook?”, vbYesNo, “Confirm Deletion”) = vbYes Then
For Each sh In ActiveWorkbook.Sheets
Once you confirm by clicking yes, you should find all sheets in your active workbook removed.
In this tutorial, we showed you how to delete charts in different cases.
This includes cases where you want a single chart removed, multiple charts removed, or all charts removed. We hope you found the tutorial and our VBA code snippets useful.
Other articles you may also like:
- How to Delete a Sheet in Excel Using VBA
- How to Delete a Comment in Excel (or Delete ALL Comments)
- How to Insert Chart Title in Excel? 2 Easy Ways
- How to Move a Chart to a New Sheet in Excel
- How to Create Org Chart in Excel? Easy Method
- How to Delete a Pivot Table? 4 Different Ways!
- Save Excel Chart as Image (High Resolution)