delete freeform vba

fboehlandt

Active Member
Joined
Sep 9, 2008
Messages
334
Hello everyone,
I wóuld like to delete all freeforms in a spreadsheet. However, even the simple command prompt refering to a particular freeform that is in the sheet does not work. What am I doing wrong? Many thanks

Code:
Sub dshape()
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Sheets("Response_Q2")
ws.Shapes("Freeform 12").Delete
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Some additional information:
The freeform is positioned on top of a chart object. Somehow this seems to be the cause of the problems although I can't imagine whay :confused:
 
Upvote 0
Try this:-
Code:
Dim shp As Shape 
For Each shp In ActiveSheet.Shapes
 If shp.AutoShapeType = 138 Then
    shp.Delete
 End If
Next shp
Mick
 
Upvote 0
Thanks for the quick reply. Still no luck :(. If I copy the freeform and paste it into the spreadsheet, then run the macro it becomes deleted. However, as long as it hovers over the chartobject it is not recognized. This is really puzzling :confused:
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top