You can use the following methods in VBA to delete charts in Excel:
Method 1: Delete All Charts on Active Sheet
Sub DeleteActiveSheetCharts()
ActiveSheet.ChartObjects.Delete
End Sub
This particular macro will delete all charts from the currently active sheet in Excel.
Method 2: Delete All Charts in Entire Workbook
Sub DeleteAllWorkbookCharts()
Dim wk As Worksheet
For Each wk In Worksheets
If wk.ChartObjects.Count > 0 Then
wk.ChartObjects.Delete
End If
Next wk
End Sub
This particular macro will delete all charts from every sheet in the entire Excel workbook.
The following examples show how to use each method in practice.
Example 1: Delete All Charts on Active Sheet
Suppose we have the following sheet in Excel that contains two charts:
We can create the following macro to delete all of the charts from this sheet:
Sub DeleteActiveSheetCharts()
ActiveSheet.ChartObjects.Delete
End Sub
When we run this macro, we receive the following output:
Notice that both charts have been deleted from the sheet.
Example 2: Delete All Charts in Entire Workbook
Suppose we have another sheet in our Excel workbook that contains two more charts:
We can create the following macro to delete all charts from both sheets in the workbook:
Sub DeleteAllWorkbookCharts()
Dim wk As Worksheet
For Each wk In Worksheets
If wk.ChartObjects.Count > 0 Then
wk.ChartObjects.Delete
End If
Next wk
End Sub
Once we run this macro, all charts from both sheets will be deleted:
Note that in this example we only deleted charts from two sheets but this macro will work with an Excel workbook with any number of sheets.
Additional Resources
The following tutorials explain how to perform other common tasks in VBA:
VBA: How to Delete Rows Based on Cell Value
VBA: How to Delete Sheet if Name Contains Specific Text
VBA: How to Delete Files