Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename multiple controls. stewart Excel Programming 0 April 15th 07 07:04 PM
Rename multiple sheets al Excel Programming 3 September 30th 05 01:11 PM
Rename Multiple Sheets from a List of Available Names prkhan56 Excel Programming 5 April 4th 05 06:07 PM
Macro to Rename Multiple Sheets Alan Excel Programming 1 January 9th 04 04:38 PM
Copy worksheet from multiple files in one DIR to another DIR & rename Mike Taylor Excel Programming 1 July 13th 03 03:28 PM


All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"