+ Reply to Thread
Results 1 to 5 of 5

Deleting Shapes

  1. #1
    Registered User
    Join Date
    09-20-2011
    Location
    Belfast
    MS-Off Ver
    Excel 2007
    Posts
    34

    Deleting Shapes

    Hello all!

    I have a macro that will add text boxes to a form template depending on the contents of cell D4:
    Please Login or Register  to view this content.
    It goes on to add another 6 text boxes to the template. If D4="FS" then it adds another 8 boxes. I want to be able to delete the boxes using a macro but can't work out how to tell it that if boxes 8 and 9 are there then delete them and if not then carry on. At the moment it gives me an error message if 8 and 9 aren't there.

    I have other shapes in there so I can't do delete all shapes.

    I hope that makes sense!

    Thanks,

    Dean
    Last edited by romperstomper; 11-25-2011 at 11:53 AM. Reason: code tags

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Deleting Shapes

    Hi,

    If it helps I recently wrote the following code to delete all shapes on a sheet - with exceptions as necessary. You may be able to adapt it.

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-20-2011
    Location
    Belfast
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Deleting Shapes

    Thanks Richard. Unfortunately I can't get it to work. Could be due to my editing!

    What I want is the macro equivelent of saying to someone "If you find the text box called 8 delete it, if not, no worries"

    The rest of this spreadsheet is working really well and this is leterally the last thing I need to do to it! So frustrating!

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Deleting Shapes

    Hi,

    In that case just
    Please Login or Register  to view this content.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Deleting Shapes

    Why so complicated ?

    You can have all these ActiveX-controls in the worksheet, set to visible=false.
    If you need them to be visible dependent on the values in the worksheet you can use .visible=true.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1