renaming array of controls

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

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?
 
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").Designer _
..Controls("CommandButton1").Name = "MyCmb1"

and looping through the collection.
 
Back
Top