ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Does an object exist? (https://www.excelbanter.com/excel-programming/385303-does-object-exist.html)

Paul Pedersen

Does an object exist?
 
I need to find an object (in this case, a picture) on a worksheet, and if it
exists, delete it. I will know ahead of time the name of the object, but how
can I avoid an error message by trying to delete it if it's not there?







Ron de Bruin

Does an object exist?
 
Hi Paul

One way is to use On Error Resume Next


On Error Resume Next
ActiveSheet.Shapes("yourshapename").Delete
On Error GoTo 0


More info here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Paul Pedersen" wrote in message ...
I need to find an object (in this case, a picture) on a worksheet, and if it
exists, delete it. I will know ahead of time the name of the object, but how
can I avoid an error message by trying to delete it if it's not there?







Paul Pedersen

Does an object exist?
 
I think I found the answer. Is "On Error Resume Next" the best way to handle
it?


"Paul Pedersen" wrote in message
...
I need to find an object (in this case, a picture) on a worksheet, and if
it exists, delete it. I will know ahead of time the name of the object, but
how can I avoid an error message by trying to delete it if it's not there?










All times are GMT +1. The time now is 12:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com