VBA Delete Chart in Excel. In this tutorial let us learn how to delete chart in Excel Workbook. We use delete method to delete chart in worksheet.
VBA Delete Chart object in Excel using VBA
Let us see how do delete the first available chart in the active sheet using VBA. In the below procedure we are using Delete method to delete specified object. Where Number 1 represents the first available chart in the worksheet.
'Delete First Available Chart using VBA Sub VBAF1_Delete_First_Chart_in_Excel() ActiveSheet.ChartObjects(1).Delete End Sub
Delete Active Chart using VBA
The below procedure or VBA code helps to delete active chart in the worksheet.
'Delete Active Chart Sub VBAF1_Delete_ActiveChart_Chart_in_Excel() ActiveChart.Parent.Delete End Sub
VBA Delete Chart by Name from the Specified Sheet
The below VBA code helps to Delete Specified Chart from specified Sheet in Excel. Where “Charts” represents the sheet name. And “Chart 2” represents the Chart name which we want to delete from the sheet.
'Delete Chart by Name from specified Sheet using VBA Sub VBAF1_Delete_Specified_Chart_in_Excel() Worksheets("Charts").ChartObjects("Chart 2").Delete End Sub
Delete Active ChartSheet
VBA procedure deletes the active chart sheet as shown below. Where delete is the method to delete chart sheet.
'Delete Active ChartSheet Sub VBAF1_Delete_Active_ChartSheet_in_Excel() ActiveSheet.Delete End Sub
VBA Delete Specified ChartSheet
Let us learn how to delete the specified chart sheet in Excel. We use delete method to delete chart sheet. Where Charts(“Chart3”) represents the Chart Sheet in a Workbook.
'Delete Specified ChartSheet Sub VBAF1_Delete_Specified_ChartSheet_in_Excel() Charts("Chart3").Delete End Sub
Instructions to Run VBA Macro Code or Procedure:
You can refer the following link for the step by step instructions.
Instructions to run VBA Macro Code
Other Useful Resources:
Click on the following links of the useful resources. These helps to learn and gain more knowledge.
VBA Tutorial VBA Functions List VBA Arrays VBA Text Files VBA Tables
VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog