View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Case Selection Example

This worked for me (attached to a command button on the userform)

Private Sub CommandButton1_Click()
Dim x As Boolean
Dim y As Boolean

x = Me.CheckBox1.Value
y = Me.CheckBox2.Value

Select Case True
Case x And y
MsgBox "Case 1"
Case x And Not y
MsgBox "Case 2"
Case Not x And y
MsgBox "Case 3"
Case Not x And Not y
MsgBox "Case 4"
End Select

End Sub

"toocold" wrote:


Hi everyone,

I think that using select case might be my best option for
accomplishing what I want to but I am really not sure. What I have is
a series of checkboxes on a userform, that a user may select to achieve
a desired result. For example, checkbox1 and checkbox2. A user has 4
options, he/she may leave both blank, select checkbox1 and leave
checkbox2 blank, select checkbox2 and leave checkbox1 blank, or select
both checkboxes.

Each of these would result in different code being ran by excel. Can
anyone give me an example of how I would set this up and use "select
case" in this instance. Or is there a better way to handle this. (In
my actual program I have six checkboxes)

Once again, thank you in advance for any advice. i
Cheers,
dw


--
toocold
------------------------------------------------------------------------
toocold's Profile: http://www.excelforum.com/member.php...o&userid=31608
View this thread: http://www.excelforum.com/showthread...hreadid=558230