Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Userform with Checkboxes
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 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Userform with Checkboxes
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 B wrote: 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 -- Dave Peterson |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Userform with Checkboxes
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) "Greg B" wrote in message ... 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 |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Userform with Checkboxes
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 "Greg B" wrote in message ... 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 |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Userform with Checkboxes
Or just use one checkbox and change the label:
Check this for Option A--leave unchecked for option B. Greg B wrote: 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 -- Dave Peterson |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Userform with Checkboxes
Bob Phillips wrote:
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Convert Worksheet to Userform | Excel Discussion (Misc queries) | |||
ability to put checkboxes into a cell (not just onto) | Excel Discussion (Misc queries) | |||
Data Validation Cell - Move to UserForm | Excel Worksheet Functions | |||
Cell Content from UserForm Not Retained | Excel Discussion (Misc queries) | |||
How can I run a macro in the background whilst a UserForm is visib | Excel Discussion (Misc queries) |