Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have four option boxes on a spreadsheet.The following code works fine but
I'd like to have it working in select case, but I don't know how to do it, any offers? Private Sub options() If opt1.Value = True Then MsgBox ("You chose A") ElseIf opt2.Value = True Then MsgBox ("You chose B") ElseIf opt3.Value = True Then MsgBox ("You chose C") ElseIf opt4.Value = True Then MsgBox ("You chose D") Else: MsgBox ("You didn't choose any") End If End Sub Sandy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub options()
Select Case True Case opt1.Value MsgBox ("You chose A") Case opt2.Value MsgBox ("You chose B") Case opt3.Value MsgBox ("You chose C") Case opt4.Value MsgBox ("You chose D") Else: MsgBox ("You didn't choose any") End If End Sub -- Regards, Tom Ogilvy "Sandy" wrote in message ... I have four option boxes on a spreadsheet.The following code works fine but I'd like to have it working in select case, but I don't know how to do it, any offers? Private Sub options() If opt1.Value = True Then MsgBox ("You chose A") ElseIf opt2.Value = True Then MsgBox ("You chose B") ElseIf opt3.Value = True Then MsgBox ("You chose C") ElseIf opt4.Value = True Then MsgBox ("You chose D") Else: MsgBox ("You didn't choose any") End If End Sub Sandy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way of doing that:
Private Sub CommandButton1_Click() Dim i As Byte On Error Resume Next For i = 1 To 5 If Controls("OptionButton" & i).Value = True Then Exit For End If Next On Error GoTo 0 Select Case i Case 1 MsgBox "option button " & i & " ticked" Case 2 MsgBox "option button " & i & " ticked" Case 3 MsgBox "option button " & i & " ticked" Case 4 MsgBox "option button " & i & " ticked" Case 5 MsgBox "no option button ticked" End Select End Sub RBS "Sandy" wrote in message ... I have four option boxes on a spreadsheet.The following code works fine but I'd like to have it working in select case, but I don't know how to do it, any offers? Private Sub options() If opt1.Value = True Then MsgBox ("You chose A") ElseIf opt2.Value = True Then MsgBox ("You chose B") ElseIf opt3.Value = True Then MsgBox ("You chose C") ElseIf opt4.Value = True Then MsgBox ("You chose D") Else: MsgBox ("You didn't choose any") End If End Sub Sandy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select case | Excel Discussion (Misc queries) | |||
Case without Select Case error problem | Excel Discussion (Misc queries) | |||
Case Select | Excel Programming | |||
Need help on Select Case | Excel Worksheet Functions | |||
select case help please | Excel Programming |