renaming array of controls

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?
 
V

Vasant Nanavati

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.
 

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