View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_629_] Leith Ross[_629_] is offline
external usenet poster
 
Posts: 1
Default Case Selection Example


Hello TooCold,

This macro is for 4 checkboxes. It converts the Checkbox value of True
(Checked) or False (Not checked) to a 1 or 0. Each checkbox value is
then multiplied by a power of 2 to create a bitmapped word of the
checkboxes states. If you want to run code for possible combination of
6 checkboxes you would have 64 Case statements.


Code:
--------------------
Sub SelectExample()

Dim ChkBox1
Dim ChkBox2

With UserForm1
ChkBox1 = Abs(.CheckBox1.Value)
ChkBox2 = Abs(.CheckBox2.Value) * 2
End With

ChkBoxes = ChkBox1 + ChkBox2

Select Case ChkBoxes
Case 0
'Code for 1 and 2 cleared
Case 1
'Code for 1 checked, 2 cleared
Case 2
'Code for 1 cleared, 2 checked
Case 3
'Code for 1 and 2 checked
End Select

End Sub

--------------------


Sincerely,
Leith Ross


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