Delete a rectangle using a macro

C

cailotto

I'm trying to delete rectangles from 170 worksheets in a workbook. I
tried highlighting each worksheet and it won't allow me to make the
change. I tried recording a macro to perform the function, but there
is an error message that says the rectangle is not found. Does anyone
know how to change this statement to have the macro run?

ActiveSheet.Shapes("Rectangle 4").Select
Selection.Characters.Text = _
 
J

Jim Rech

This deletes all the rectangles in the active workbook.

Sub DelRects()
Dim WS As Worksheet
For Each WS In Worksheets
WS.Rectangles.Delete
Next
End Sub

I don't think that's what you want to do but at least this will give you an
opportunity to clarify.

--
Jim
| I'm trying to delete rectangles from 170 worksheets in a workbook. I
| tried highlighting each worksheet and it won't allow me to make the
| change. I tried recording a macro to perform the function, but there
| is an error message that says the rectangle is not found. Does anyone
| know how to change this statement to have the macro run?
|
| ActiveSheet.Shapes("Rectangle 4").Select
| Selection.Characters.Text = _
|
 
G

Guest

there is a good chance that the rectangle has a different name on each sheet.
if you want to delete all shapes on a sheet

Sub spdel()
For n = ActiveSheet.Shapes.Count To 1 Step -1
ActiveSheet.Shapes(n).Delete
Next n
End Sub

you can make it more complex by looking for Rec in the name of the shape if
it os only retangles you want to delete
 

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

Top