Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Greg B
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Greg B
 
Posts: n/a
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Worksheet to Userform Brian C Excel Discussion (Misc queries) 1 October 3rd 05 08:08 PM
ability to put checkboxes into a cell (not just onto) jayjay17 Excel Discussion (Misc queries) 3 July 19th 05 09:01 PM
Data Validation Cell - Move to UserForm thom hoyle Excel Worksheet Functions 0 April 28th 05 12:23 AM
Cell Content from UserForm Not Retained D.Parker Excel Discussion (Misc queries) 3 April 27th 05 04:56 PM
How can I run a macro in the background whilst a UserForm is visib cdb Excel Discussion (Misc queries) 3 February 10th 05 06:58 PM


All times are GMT +1. The time now is 04:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"