View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default 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.