ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clearing rectangles (https://www.excelbanter.com/excel-programming/358149-clearing-rectangles.html)

Andrew B[_5_]

Clearing rectangles
 
Hi

I have a number of rectangles that I want to delete from an area on a
worksheet. What is the quickest way to do this ?

I have tried the following but it didn't quite work ...

Sub rem1()
Set Shr = Sheets("Reports")


For Each Rectangle In Shr.Range("B26:V53") ' graph area
Rectangle.Delete
Next

End Sub


Thanks in advance

Andrew B

Dave Peterson

Clearing rectangles
 
Can you just look at the topleftcell of the shape?

option explicit
sub rem2()
dim myRect as Rectangle
dim myRng as range

set myrng=worksheets("Reports").range("B26:v53")

for each myrect in myrng.parent.rectangles
if intersect(myrect.topleftcell, myrng) is nothing then
'not in that area
else
myrect.delete
end if
end sub

(Untested--so watch out for typos!)

Andrew B wrote:

Hi

I have a number of rectangles that I want to delete from an area on a
worksheet. What is the quickest way to do this ?

I have tried the following but it didn't quite work ...

Sub rem1()
Set Shr = Sheets("Reports")

For Each Rectangle In Shr.Range("B26:V53") ' graph area
Rectangle.Delete
Next

End Sub

Thanks in advance

Andrew B


--

Dave Peterson


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

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