Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8654927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:54:24+00:00 2026-06-12T14:54:24+00:00

I have an excel worksheet where a macro tied to a button draws dynamic

  • 0

I have an excel worksheet where a macro tied to a button draws dynamic shapes based on the user input parameters in the worksheet.

I am trying to write a new macro to clean the sheet, or in other words delete all shapes in the worksheet.

I tried using the code below, and it indeed deletes all shapes, however button form controls also get deleted in the process. Is there an easy way to only get rid of the shapes (arrows, textboxes, ellipses etc.) in the worksheet? Thanks a bunch!!!

Sub DeleteAllShapes()

Dim Shp As Shape

For Each Shp In ActiveSheet.Shapes
    Shp.Delete
Next Shp

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:54:27+00:00Added an answer on June 12, 2026 at 2:54 pm

    To delete autoshapes and textboxes only you can use:

    Sub DeleteAllShapes()
    
    Dim Shp As Shape
    
    For Each Shp In ActiveSheet.Shapes
        If Shp.Type = msoAutoShape Or Shp.Type = msoTextBox Then Shp.Delete
    Next Shp
    
    End Sub
    

    Alternatively you can work the other way around and specify the types not to delete. You can use the enumerated types but it’s more readable to use the type names. The following snippet will delete everything apart from Form Controls and OLE control objects.

    Sub DeleteAllShapes()
    
    Dim Shp As Shape
    
    For Each Shp In ActiveSheet.Shapes
        If Not (Shp.Type = msoOLEControlObject Or Shp.Type = msoFormControl) Then Shp.Delete
    Next Shp
    
    End Sub
    

    A full list of MSO Shape Types.
    http://msdn.microsoft.com/en-us/library/office/aa432678(v=office.12).aspx

    Ron de Bruin has a good collection of snippets which may be relevant to anyone else coming across this question.
    http://www.rondebruin.nl/controlsobjectsworksheet.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a macro that allows a user to browse and select multiple Excel
I have a VBA publishing macro in Excel which generates a published workbook based
I have an Excel worksheet that has the following macro. I'd like to loop
I have a VBA macro that copies rows from one worksheet into another based
I have created a simple excel worksheet. This is my macro code: Sub MyMacro()
I have a chart in a Worksheet in Excel and I have a macro
Using Windows XP and Excel 2007 I have a worksheet with a macro in
I have the following Excel worksheet: | A B C -+--------------- 1|id date views
I am creating an Excel Worksheet from C# using Microsoft.Office.Interop.Excel, and I have not
I have an Excel 2010 workbook for financial records. On one worksheet, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.