Table of Contents
VBA (Visual Basic for Applications) is a programming language used to automate tasks in Microsoft Excel. With VBA, users can manipulate and delete charts within their Excel workbooks. To delete a chart using VBA, the user can use the “Chart.Delete” method, which will remove the selected chart from the worksheet. Alternatively, the “Charts.Delete” method can be used to delete all charts within a workbook.
Some examples of VBA code for deleting charts include:
1. Deleting a specific chart:
Sub DeleteSpecificChart()
ActiveSheet.ChartObjects(“Chart 1”).Delete
End Sub
2. Deleting all charts on a specific worksheet:
Sub DeleteAllCharts()
Dim cht As ChartObject
For Each cht In ActiveSheet.ChartObjects
cht.Delete
Next cht
End Sub
3. Deleting all charts in a workbook:
Sub DeleteAllChartsInWorkbook()
Dim ws As Worksheet
Dim cht As ChartObject
For Each ws In ThisWorkbook.Worksheets
For Each cht In ws.ChartObjects
cht.Delete
Next cht
Next ws
End Sub
By using VBA, users can easily delete charts in Excel with just a few lines of code, saving time and effort in managing their data and reports.
Delete Charts Using VBA (With Examples)
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 IfNext 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 SubWhen 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

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 IfNext wk
End SubOnce 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.
Cite this article
stats writer (2024). How can charts be deleted using VBA, and what are some examples of VBA code for deleting charts?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-charts-be-deleted-using-vba-and-what-are-some-examples-of-vba-code-for-deleting-charts/
stats writer. "How can charts be deleted using VBA, and what are some examples of VBA code for deleting charts?." PSYCHOLOGICAL SCALES, 24 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-charts-be-deleted-using-vba-and-what-are-some-examples-of-vba-code-for-deleting-charts/.
stats writer. "How can charts be deleted using VBA, and what are some examples of VBA code for deleting charts?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-charts-be-deleted-using-vba-and-what-are-some-examples-of-vba-code-for-deleting-charts/.
stats writer (2024) 'How can charts be deleted using VBA, and what are some examples of VBA code for deleting charts?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-charts-be-deleted-using-vba-and-what-are-some-examples-of-vba-code-for-deleting-charts/.
[1] stats writer, "How can charts be deleted using VBA, and what are some examples of VBA code for deleting charts?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can charts be deleted using VBA, and what are some examples of VBA code for deleting charts?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
