ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   OptionButton in a Form (https://www.excelbanter.com/excel-programming/340395-optionbutton-form.html)

Fred Russell

OptionButton in a Form
 
I'm using 60 OptionButtons in a form. To initialize, I want all the
OptionButtons invisible. How can I index the OptionButtons with a For-Next
Loop to accomplish this? I've tried numerous approaches with no luck at
all... Plenty of error messages.

Any help appreciated.

Thanks,
Fred



Norman Jones

OptionButton in a Form
 
Hi Fred,

Try:

'=======================
Private Sub UserForm_Initialize()
Dim oleObj As MSForms.OptionButton

For Each oleObj In UserForm1.Controls
If TypeOf oleObj Is MSForms.OptionButton Then
oleObj.Visible = False
End If
Next
End Sub

'<<=======================

---
Regards,
Norman



"Fred Russell" wrote in message
...
I'm using 60 OptionButtons in a form. To initialize, I want all the
OptionButtons invisible. How can I index the OptionButtons with a
For-Next Loop to accomplish this? I've tried numerous approaches with no
luck at all... Plenty of error messages.

Any help appreciated.

Thanks,
Fred





Bob Phillips[_6_]

OptionButton in a Form
 
Probably best to declare the variable as Control

Dim oleObj As msforms.Control


--
HTH

Bob Phillips

"Norman Jones" wrote in message
...
Hi Fred,

Try:

'=======================
Private Sub UserForm_Initialize()
Dim oleObj As MSForms.OptionButton

For Each oleObj In UserForm1.Controls
If TypeOf oleObj Is MSForms.OptionButton Then
oleObj.Visible = False
End If
Next
End Sub

'<<=======================

---
Regards,
Norman



"Fred Russell" wrote in message
...
I'm using 60 OptionButtons in a form. To initialize, I want all the
OptionButtons invisible. How can I index the OptionButtons with a
For-Next Loop to accomplish this? I've tried numerous approaches with

no
luck at all... Plenty of error messages.

Any help appreciated.

Thanks,
Fred







Norman Jones

OptionButton in a Form
 
Hi Bob,

Agreed!

---
Regards,
Norman



"Bob Phillips" wrote in message
...
Probably best to declare the variable as Control

Dim oleObj As msforms.Control


--
HTH

Bob Phillips

"Norman Jones" wrote in message
...
Hi Fred,

Try:

'=======================
Private Sub UserForm_Initialize()
Dim oleObj As MSForms.OptionButton

For Each oleObj In UserForm1.Controls
If TypeOf oleObj Is MSForms.OptionButton Then
oleObj.Visible = False
End If
Next
End Sub

'<<=======================

---
Regards,
Norman



"Fred Russell" wrote in message
...
I'm using 60 OptionButtons in a form. To initialize, I want all the
OptionButtons invisible. How can I index the OptionButtons with a
For-Next Loop to accomplish this? I've tried numerous approaches with

no
luck at all... Plenty of error messages.

Any help appreciated.

Thanks,
Fred









Fred Russell

OptionButton in a Form
 
Thanks Norman and Bob, I really appreciate your help. Recommendation worked
just fine when using Norman's code with Bob's suggestion on the dimension
statement.

Dim oleObj As msforms.Control

Best regards,
Fred




All times are GMT +1. The time now is 08:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com