ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Picture VBA If Then Problem (https://www.excelbanter.com/excel-programming/371044-delete-picture-vba-if-then-problem.html)

Shawn

Delete Picture VBA If Then Problem
 
Here is my code and it works: Sheets("T.S.").Shapes("Picture 1").Delete

However, there isn't always a "Picture 1". I would like an If Then
statement. For example:

If Sheets("T.S.").Shapes("Picture 1") = True Then
Sheets("T.S.").Shapes("Picture 1").Delete

Now I know that won't work but you get the idea.



--
Thanks
Shawn

Dave Peterson

Delete Picture VBA If Then Problem
 
How about:

on error resume next
Sheets("T.S.").Shapes("Picture 1").Delete
on error goto 0

Just ignore the error if the picture doesn't exist.

Shawn wrote:

Here is my code and it works: Sheets("T.S.").Shapes("Picture 1").Delete

However, there isn't always a "Picture 1". I would like an If Then
statement. For example:

If Sheets("T.S.").Shapes("Picture 1") = True Then
Sheets("T.S.").Shapes("Picture 1").Delete

Now I know that won't work but you get the idea.

--
Thanks
Shawn


--

Dave Peterson


All times are GMT +1. The time now is 07:46 PM.

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