+ Reply to Thread
Results 1 to 3 of 3

How to delete MSOSHAPELEFTARROW only

Hybrid View

  1. #1
    Registered User
    Join Date
    06-09-2009
    Location
    Capitola, California
    MS-Off Ver
    Excel 2003
    Posts
    25

    How to delete MSOSHAPELEFTARROW only

    Using VBA Excel, I am having a hard time deleting ONLY specific shapes (they are all left Arrows and are situated in range E10:E20.

    I am trying to delete JUST these msoshapeLeftArrow that are located in that range of the worksheet without deleting any other shapes like buttons and drop down boxex etc....

    I was trying:

    Sub Pointersdelete()
    
    Dim Sh As Shape
    Dim Ws As Worksheet
    
    Set Ws = ActiveSheet
    
    
    With Ws
    For Each Sh In .Shapes
    If Sh.Type = msoShapeLeftArrow Then Sh.Delete
    Next Sh
    End With
           
        
    
    End Sub
    This is not working because the above code deletes EVERY shape in my worksheet.

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: How to delete MSOSHAPELEFTARROW only

    Hi mhni

    Try:

    Sub Pointersdelete()
    
    Dim Sh As Shape
    Dim Ws As Worksheet
    
    Set Ws = ActiveSheet
    
    With Ws
        For Each Sh In .Shapes
            If Sh.Type = msoAutoShape And Sh.AutoShapeType = msoShapeLeftArrow Then _
                If Not Intersect(Range(Sh.TopLeftCell, Sh.BottomRightCell), Range("E10:E20")) Is Nothing Then _
                    Sh.Delete
        Next Sh
    End With
           
    End Sub

  3. #3
    Registered User
    Join Date
    06-09-2009
    Location
    Capitola, California
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: How to delete MSOSHAPELEFTARROW only

    Works like a charm....many thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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