Userform with Checkboxes

  • Thread starter Thread starter Greg B
  • Start date Start date
G

Greg B

Hi all,

I have a userform where I use checkboxes for the person to select either
one or the other.

I need help with a macro to check if either of checkbox1 or checkbox2
has been selected, but to also check that they both haven't been
selected at the same time.

How can I do this?

Thanks
Greg
 
You could do that, but why not just use a couple of option buttons--then when
you choose one, the other is unchosen.

if me.checkbox1.value = true _
and me.checkbox2.value = true then
msgbox "not both!
exit sub '???
end if

might be one way to validate in your "ok" button.
 
Greg,

A perfect case for optionbuttons. When one is set, the other unsets. Code
like

With Me
If Optionbutton1 Then
'do button1 stuff
Else
'do button 2 stuff
End If
End WIth

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
If you only want one option to be selected, but not both, you
might use Option Button controls instead of check boxes -- they
designed for just this purpose.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Or just use one checkbox and change the label:

Check this for Option A--leave unchecked for option B.
 
Bob said:
Greg,

A perfect case for optionbuttons. When one is set, the other unsets. Code
like

With Me
If Optionbutton1 Then
'do button1 stuff
Else
'do button 2 stuff
End If
End WIth
Thanks for the help, I never even considered that option

Thanks

Greg
 
Back
Top