Array of OptionButtons ?

M

MWE

I have an application with a userform that uses optionbuttons. Th
number of optionbuttons is dynamically defined by the application. Th
buttons are presently "optionbutton1", "optionbutton2", etc (i.e., th
default names). Is there a way to manipulate the option buttons as a
array, i.e., something like optionbutton(i) ? I have tried somethin
like

Dim opButton as OptionButton

I = 0
For each opButton in frmSelectPro
 
T

Tom Ogilvy

Dim obtn as MSForms.OptionButton
for each ctrl in userform1.controls
if typeof ctrl is MSForms.OptionButton then
set obtn = ctrl
msgbox obtn.Name
end if
Next
 
G

Guest

Use this: assumes you are using default optionbutton names
Private Sub GetOpts(
Dim c As Contro
For Each c In Control
If c.Name Like "optionbutton*" the
. ..Your code her
End i
Nex
End Su
----- MWE > wrote: ----

I have an application with a userform that uses optionbuttons. Th
number of optionbuttons is dynamically defined by the application. Th
buttons are presently "optionbutton1", "optionbutton2", etc (i.e., th
default names). Is there a way to manipulate the option buttons as a
array, i.e., something like optionbutton(i) ? I have tried somethin
lik

Dim opButton as OptionButto

I =
For each opButton in frmSelectPro
 
M

MWE

Tom said:
Dim obtn as MSForms.OptionButton
for each ctrl in userform1.controls
if typeof ctrl is MSForms.OptionButton then
set obtn = ctrl
msgbox obtn.Name
end if
Next


Tom: thanks, this works.

MW
 

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