ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check for a shape - then change or delete it if it exists (https://www.excelbanter.com/excel-programming/390349-check-shape-then-change-delete-if-exists.html)

Mona-ABE

Check for a shape - then change or delete it if it exists
 
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)?

--
Thanks!
Mona-ABE

WhytheQ

Check for a shape - then change or delete it if it exists
 
Dim myShape
if ActiveSheet.shapes.count0 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




On 30 May, 14:25, Mona-ABE wrote:
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)?

--
Thanks!
Mona-ABE




Tim

Check for a shape - then change or delete it if it exists
 
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


"Mona-ABE" wrote in message
...
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)?

--
Thanks!
Mona-ABE





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

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