Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Rename multiple controls.
I have a multipage on a userfrom with 92 optionbuttons. I would like
to change the names from OptionButton1 to opt1. I have seen posts that includes loops to rename controls but i can find it at the moment. Any help is appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Rename multiple controls.
For a form named "UserForm1" with a multipage named "MultiPage1", you'll need
code like the one below. You will need to enable trust access to Visual Basic Project (Tools-Macro-Security, in Trusted Publishers tab, check "Trust access to Visual Basic Project". Also work on a BACKUP copy first to be safe. Sub test() Dim pg As Page Dim o As Control For Each pg In ThisWorkbook.VBProject.VBComponents("UserForm1").D esigner.Controls("MultiPage1").Pages For Each o In pg.Controls If TypeOf o Is MSForms.OptionButton Then o.Name = Replace(o.Name, "OptionButton", "opt") End If Next o Next pg End Sub -- Hope that helps. Vergel Adriano "stewart" wrote: I have a multipage on a userfrom with 92 optionbuttons. I would like to change the names from OptionButton1 to opt1. I have seen posts that includes loops to rename controls but i can find it at the moment. Any help is appreciated. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Rename multiple controls.
Did exactly what I wanted it to. Thank you so much.
Vergel Adriano wrote: For a form named "UserForm1" with a multipage named "MultiPage1", you'll need code like the one below. You will need to enable trust access to Visual Basic Project (Tools-Macro-Security, in Trusted Publishers tab, check "Trust access to Visual Basic Project". Also work on a BACKUP copy first to be safe. Sub test() Dim pg As Page Dim o As Control For Each pg In ThisWorkbook.VBProject.VBComponents("UserForm1").D esigner.Controls("MultiPage1").Pages For Each o In pg.Controls If TypeOf o Is MSForms.OptionButton Then o.Name = Replace(o.Name, "OptionButton", "opt") End If Next o Next pg End Sub -- Hope that helps. Vergel Adriano "stewart" wrote: I have a multipage on a userfrom with 92 optionbuttons. I would like to change the names from OptionButton1 to opt1. I have seen posts that includes loops to rename controls but i can find it at the moment. Any help is appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Rename multiple controls. | Excel Programming | |||
Rename multiple sheets | Excel Programming | |||
Rename Multiple Sheets from a List of Available Names | Excel Programming | |||
Macro to Rename Multiple Sheets | Excel Programming | |||
Copy worksheet from multiple files in one DIR to another DIR & rename | Excel Programming |