validate an option is chosen

D

DaveB

I have 2 option buttons in a form. The worksheet is
emailed with a macro. How can I validate in my macro that
one of the option buttons has been selected. In other
words I would like a message box to pop up saying "You
must make a selection before emailing" if the user does
not select one of the option buttons.

thanks
 
O

Owen

You can validate the values by nesting IF Statements at
the beginning of your code...

HTH
Owen

If Sheet1.OptionButton1 = Sheet1.OptionButton2 Then
If Sheet1.OptionButton2 = False Then
Dim lMsg As Long
lMsg = MsgBox("Select an Option Fool", vbOKOnly +
vbExclamation, "No Selection Made")
End If
End If
 
B

Bob Phillips

Dave,

One way for forms option buttons

If ActiveSheet.OptionButtons("Option Button 1").Value = xlOff And _
ActiveSheet.OptionButtons("Option Button 2").Value = xlOff Then
MsgBox "One must be selected"
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
G

Guest

Worked great, Much appreciated.
-----Original Message-----

You can validate the values by nesting IF Statements at
the beginning of your code...

HTH
Owen

If Sheet1.OptionButton1 = Sheet1.OptionButton2 Then
If Sheet1.OptionButton2 = False Then
Dim lMsg As Long
lMsg = MsgBox("Select an Option Fool", vbOKOnly +
vbExclamation, "No Selection Made")
End If
End If


.
 
Top