Re-naming controls on a form

SiddersAtHome

Board Regular
Joined
Nov 2, 2005
Messages
119
Hi

I have created a form which I want to add 20 labels to. By default if I just add them off the tool box, they will be called Label1 Label2 Label3 etc.

However, I want these labels to appear in two columns which will eventually hold input and output file names. Instead of having a piece of code that "calculates" which column a label is in particularly as I may be adding more label later, is there a way that I can re-name the labels to my own naming convention without having to edit all the names individually in the properties box.

So, I would like to rename the first 10 labels as lblInput1, lblInput2 etc. and the next 20 as lblOutput1, lblOutput2 and so on.

I have tried running some vb code using ctl.name = "lblInput" & MyCounter but I get an error saying this cannot be done in runtime.

I would prefer that I could then save the form (or the workbook the form is on) so that next time I open it, they still have their new names. Worst case is I have to run the re-name code every time I open the file which would not be ideal but workable.

Many thanks

Sidders
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,224,518
Messages
6,179,259
Members
452,901
Latest member
LisaGo

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