+ Reply to Thread
Results 1 to 3 of 3

Delete A Range Of Objects

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-09-2008
    Location
    Middlesbrough, England
    MS-Off Ver
    2007
    Posts
    174

    Delete A Range Of Objects

    Hi,

    I've created a worksheet and for some reason, additional objects have been added.

    Rather than selecting all objects and deleting (don't want to do this as took me a long time added macros to current buttons).

    I would like to delete the objects called Button 123 to Button 1296.

    Still learning VB and tried the following which cant be far away?

    Sub Delete()
    
        Dim v As Variant
        
        For i = 123 To 1296
        ActiveSheet.Shapes.Range("Button " & i).Delete = Sub Delete
    Next i
    
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Delete A Range Of Objects

    Does this work?
    [code]
    Sub DeleteShapes()

    Dim I As Long

    For I = 123 To 1296
    On Error Resume Next
    ActiveSheet.Shapes("Button " & i).Delete
    On Error Goto 0
    Next I

    End Sub
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    09-09-2008
    Location
    Middlesbrough, England
    MS-Off Ver
    2007
    Posts
    174

    Re: Delete A Range Of Objects

    Excellent, works a charm.

    Thankyou

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. unable to delete or remove objects ? :(
    By VICTOR55 in forum Excel General
    Replies: 2
    Last Post: 01-05-2014, 07:36 AM
  2. Locate and delete objects
    By hutch@edge.net in forum Excel General
    Replies: 5
    Last Post: 12-31-2009, 01:48 PM
  3. Delete all Word Objects only
    By roasty_1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-15-2008, 05:17 PM
  4. Delete Picture Objects
    By The Other Mike in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-09-2006, 02:15 PM
  5. Delete All Picture Objects Using VBA
    By Nathan Bell in forum Excel General
    Replies: 3
    Last Post: 04-12-2005, 03:06 PM

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