VBA Code to Delete All Shapes from Excel Sheet

VBA Code to Delete All Shapes from Excel Sheet

Here is a VBA code which deletes all the shapes from an Excel sheet. Code is simple but you have to be bit careful while using this code as it deletes all the Shapes, Smart Shapes, Charts, Pictures, Objects and Equations from the sheet

Excel Tricks

'Following function deletes all the Shapes, Smart Shapes, Charts,
'Pictures, Objects and Equations from the Excel worksheet
Sub DeleteShapesFromSheet()
    'Declare variable
    Dim objShape As Shape
    'Loop through all the shapes from sheet1 and delete
    For Each objShape In Sheet1.Shapes
        objShape.Delete
    Next
End Sub

 

To use this code in your Excel file, follow below steps:

1. Open an Excel file
2. Press Alt+F11
3. Insert a Module (Insert>Module) from menu bar
4. Paste the code in the module
5. Click on ‘View Macros’ option available under View>Macros ribbon

Excel Tricks

6. Select ‘DeleteShapesFromSheet’ and click on Run

Excel Tricks

7. Done

Author:
Excelsirji.com was started with the thought of making people experience easy while working with Excel, data analytics, vba, automations etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you a Data Enthusiast?

Join us for a ride on your data and automate your stuffs

Business Analytics
Data Analyst
Programming for Data Science
Predictive Analytics for Business