View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Susan Susan is offline
external usenet poster
 
Posts: 1,117
Default Looping through Option buttons

also, i don't see anything "dimmed".

you'd need
Dim optProject as Control

and i missed this

For Each optProject In fraProject.Controls

you don't need to refer to "me" because you're already in the userform
initialization sub.

:)
susan


On May 7, 12:00 pm, Ayo wrote:
I am getting the "Subscript out of range" error. And I can't figure out what
I am doing wrong.



"Susan" wrote:
what error are you getting? or does it simply not work?


you're close: :)


For Each optProject In Me.fraProject
If optProject.Value = True Then
optProject.Enabled = True
Else

optProject.Enabled = False
End If
Next optProject


you don't have to tell it "if it's false" because there's only 2
options, true or false. so if it's not true, then it's obviously
false.


and you don't need the With Me.fraProject line because you're already
telling it with what in the for-each statement.


hope it helps!
susan


On May 7, 11:37 am, Ayo wrote:
I am having a problem with this set of code below. What I am trying to do is
to disable all the option buttons in the frame, except for the active option
button, when the form initializes. Or, if no option button is selected in the
frame, I want all the option buttons to be enabled but if one option button
is selected, I want the rest of the option buttons to be disabled.
How can I write the code to do that?


With Me.fraProject
For Each optProject In Me.fraProject
If .optProject.Value = True Then
.optProject.Enabled = True
ElseIf .optProject.Value = False Then
.optProject.Enabled = False
End If
Next
End With- Hide quoted text -


- Show quoted text -