Identify and delete the specified objects names
Thanks Ryan, I have used the code you provided but unfortunately, I still
encounter the same problem with the runtime error 1004 at Shp.Delete.
Look forward to your advice. Thanks again. Loy
"Ryan H" wrote:
I didn't test this, but try this. Hope this helps! If so, click "YES" below.
Public Sub Deleteonstrfr()
Dim Shp As Shape
For Each Shp In Sheets("SLD").Shapes
If Left(Shp.Name, 7) = "onstrfr" Then
Shp.Delete
End If
Next Shp
End Sub
--
Cheers,
Ryan
"newbie" wrote:
I used the following code that allows me to identify and delete a specific
object in the worksheet via a user interface. The code works this morning but
don't know why, when or how, this Runtime Error 1004: Application or
object-defined error. appears at the line every time the program tries to
delete the object. Someone suggested me to use clean registry but I have not
really tried it yet. Is there a way to avoid this problem? I hope to find a
simple way that can perform the same function as the following code? Your
advice or help will be greatly appreciated.
Thanks.
Public Sub Deleteonstrfr()
Dim Obj As Object
For Each Obj In Sheets("SLD").Shapes
If Left(Obj.Name, 7) = "onstrfr" Then
Obj.Delete '***Run-time Error found at here'
End If
Next Obj
End Sub
|