View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default verify state of option button

try this
Sub verify()

Select Case True
Case Me.OptionButton1.Value
'code here
Case Me.OptionButton2.Value
'code here
Case Me.OptionButton3.Value
'code here
Case Me.OptionButton4.Value
'code here
Case Else
'code here
End Select

End Sub
"stewart" wrote:

I have a group of four option buttons on a userform. The user is
required to check select one of them. What can I put in my code to
verify this. What I currently have is below but it does not seem like
it is the most efficient way of completing this task as I have this
occurrence 34 separate times.


sub verify()
If opt1.Value = False And opt2.Value = False And opt3.Value = False
And opt4.Value = False Then
GoTo 2:
ElseIf opt5.Value = False And opt6.Value = False And opt7.Value =
False And opt8.Value = False Then
GoTo 2
end if

'other code below
....
exit sub
2: msgbox "Please verify that you have completed each section"
end sub