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
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
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
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
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
You can refer the following link for the step by step instructions.
Click on the following links of the useful resources. These helps to learn and gain more knowledge.