can't enter breaking mode when deleting shapes

  • Hi,
    I need to maintain a macro, where I need to delete shapes from the sheet then close it.
    My problem is that when the code hits the deletion-part it breaks and shows "Cannot enter break mode now". I can continue the run, and the shapes get deleted, but it ends with "invalid procedure" message and it quits, I cannot debug it after this message.
    Originally it was written in an earlier version of excel, I have saved it as xlsm before starting the modification.
    I do it like this:


    Does anybody any clue what is the problem?
    Thank you

  • try this

    Dim sh As Shape
    For Each sh In ActiveSheet.Shapes
    If sh.Name = "Approve" Or sh.Name = "Reject" Then sh.Delete
    Next sh
  • Thanks, I will. But do you know why does it return this strange behavior? I never seen this "cant enter into breakmode" thing before.

  • The only thing I can think of is either the shape doesn't exist in the sheet or has a slightly different name. Case sensitive applies. so if you wanna remove case sensitivity then you need to change sh.Name = to sh.Name Like

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!