ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   deleting form controls by code (https://www.excelbanter.com/excel-programming/359606-deleting-form-controls-code.html)

Bri[_3_]

deleting form controls by code
 
Hello

I' like to USE CODE to delete controls from a worksheet. I hope to use the
code on several sheets.

I used 'Record Macro' to come up with the following, which works well on the
1st sheet ...

Application.CommandBars("Drawing").Visible = True
ActiveSheet.Shape.Range(Array("chbx1", "chbx2", "optbx1")).Select
Selection.Delete
Application.CommandBars("Drawing").Visible = False

The problem is that different sheets have different numbers of controls,
sometimes with different names, so the Array part of the code above crashes.
What code can I use to delete all form controls from a given page?

Thank you
Bri




Ron de Bruin

deleting form controls by code
 
Hi Bri

See
http://www.rondebruin.nl/controlsobjectsworksheet.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Bri" wrote in message ...
Hello

I' like to USE CODE to delete controls from a worksheet. I hope to use the code on several sheets.

I used 'Record Macro' to come up with the following, which works well on the 1st sheet ...

Application.CommandBars("Drawing").Visible = True
ActiveSheet.Shape.Range(Array("chbx1", "chbx2", "optbx1")).Select
Selection.Delete
Application.CommandBars("Drawing").Visible = False

The problem is that different sheets have different numbers of controls, sometimes with different names, so the Array part of the
code above crashes. What code can I use to delete all form controls from a given page?

Thank you
Bri






Bri[_3_]

deleting form controls by code
 
Ron - MOST helpful
Thanks
Bri




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

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