ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   renaming array of controls (https://www.excelbanter.com/excel-programming/302924-renaming-array-controls.html)

Jason[_31_]

renaming array of controls
 
from the default CommandButton1,2,3........100.

to

MyCmb1,2,3.....100


I tried

Dim x As Single
For x = 1 To 100
Controls("CommandButton" & x).Name = "MyCmb" & x
Next x

error "Can't set at runtime"

how else can I quickly change these?





Vasant Nanavati

renaming array of controls
 
I would assume that if the property cannot be set at runtime, there is no
way of doing it.

If you are just trying to effect a mass change, you can do it at design-time
using the syntax:

ThisWorkbook.VBProject.VBComponents("UserForm1").D esigner _
..Controls("CommandButton1").Name = "MyCmb1"

and looping through the collection.

--

Vasant

"Jason" wrote in message
...
from the default CommandButton1,2,3........100.

to

MyCmb1,2,3.....100


I tried

Dim x As Single
For x = 1 To 100
Controls("CommandButton" & x).Name = "MyCmb" & x
Next x

error "Can't set at runtime"

how else can I quickly change these?








All times are GMT +1. The time now is 12:14 PM.

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