Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Does Shape Exist?

Using VBA how can I determine whether a shape (e.g. a rectangle) with a
specific user defined name actually exists before I try to delete it?

thanks ...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Does Shape Exist?

Hi Alan

You can use a on error

On Error Resume Next
'your delete code
On Error GoTo 0


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alan" wrote in message oups.com...
Using VBA how can I determine whether a shape (e.g. a rectangle) with a
specific user defined name actually exists before I try to delete it?

thanks ...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Does Shape Exist?

If you really want to test for its existence, use code like


Dim SH As Shape
Set SH = ActiveSheet.Shapes("MyRect")
If Not SH Is Nothing Then
SH.Delete
End If

However, it would be simple to attempt to delete the shape and
ignore any error that occurs:

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


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Alan" wrote in message
oups.com...
Using VBA how can I determine whether a shape (e.g. a
rectangle) with a
specific user defined name actually exists before I try to
delete it?

thanks ...



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Does Shape Exist?


Thanks guys.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Copy Worksheet to a new Workbook creating if it doesn't exist and add more Worksheets if it does exist [email protected] Excel Programming 4 June 18th 06 06:08 PM
Command Line. How to tell to XL : If the xls file exist : Open it, if it does not exist : Create it. Tintin92 Excel Programming 3 March 11th 06 06:45 PM
Deleting a shape and the cell contents the shape is in. Dave Peterson[_3_] Excel Programming 1 October 9th 03 03:36 PM
Deleting a shape and the cell contents the shape is in. Tom Ogilvy Excel Programming 0 October 9th 03 03:43 AM


All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"