How do I put an if clause into a bit of code to basically say, if it exists then do this
I have some objects which I want delete and then recreate, however if the user has already deleted the object and it no longer exists then it gives me an error.
I have some objects which I want delete and then recreate, however if the user has already deleted the object and it no longer exists then it gives me an error.
Code:
ActiveSheet.Shapes("Donut1").Delete
ActiveSheet.Shapes("Donut2").Delete
ActiveSheet.Shapes.AddShape(msoShapeDonut, 42, 1836, 20, 18).Select
Selection.ShapeRange.Name = "Donut1"
Selection.Name = "Donut1"
ActiveSheet.Shapes.AddShape(msoShapeDonut, 65, 1836, 20, 18).Select
Selection.ShapeRange.Name = "Donut2"
Selection.Name = "Donut2"