Check for a shape - then change or delete it if it exists

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a spreadsheet which contains lines that have been drawn using vba.
During the drawing the process they are named like this myLine.Name = "Arrow"
& CStr(PasteRow). The variables "myline" (shape object) and "pasterow" (long
number)have been declared and defined. When content on the spreadsheet
changes the arrows' positions and lengths can be affected, or they may be
deleted if no longer needed. I need to search to see if an arrow exists,
change it and or delete it. What do you suggest (using Excel 2003 SP2)?
 
Dim myShape
if ActiveSheet.shapes.count>0 then
for each myShape in ActiveSheet.shapes
if myShape.name = "Arrow" then

'stick code in here for the actions you want to take once
this shape has been found

end if
next
end if


Not sure if the above helps - but maybe its a start
J
 
dim s

on error resume next
set s=activesheet.shapes(shapename)
on error goto 0

if not s is nothing then
.... do something with s
end if

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top