Message box to appear if option not selected

joacro

Board Regular
Joined
Jun 24, 2010
Messages
158
Hi there

I wish that a message box to appear if no option is selected:
- if txtCh1 = true and opt 1, opt2 or opt3 is not selected then msgbox (please select age group of child / adult dependant)
- if txtCh2 = true and opt4, opt5 or opt6 is not selected then msgbox (please select age group of child / adult dependant)
- if txtCh3 = true and opt7, opt8 or opt9 is not selected then msgbox (please select age group of child / adult dependant)
- if txtCh4 = true and opt10, opt11 or opt12 is not selected then msgbox (please select age group of child / adult dependant)
- if txtCh5 = true and opt13, opt14 or opt 15is not selected then msgbox (please select age group of child / adult dependant)
- if txtCh6 = true and opt16, opt17 or opt18 is not selected then msgbox (please select age group of child / adult dependant)

Hope someone can help me with this

Thanx in advance

Joacro
 
Changing this line should do that
Code:
On Error Resume Next
    pollOptGroup = Not (pollOptGroup) Imp CBool(Len(Me.Controls(textName).Text))
    On Error GoTo 0
End Function
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try adding a command button to the userform. then use this code:

Code:
Private Sub CommandButton1_Click()
Dim i As Long
Dim j As Long
j = 0
    For i = 1 To 6
        If UCase(Me.Controls("txtCh" & i).Value) = "TRUE" [COLOR=red]And[/COLOR] Me.Controls("opt" & j + 1).Value = False [COLOR=red]And[/COLOR] _
                Me.Controls("opt" & j + 2).Value = False [COLOR=red]And[/COLOR] Me.Controls("opt" & j + 3).Value = False Then
            MsgBox "please select age group of child / adult dependant"
        End If
        j = j + 3
    Next i
End Sub

call the userform and test to see if anything happens...


You could try changing the And to Or.
 
Upvote 0
I just had a thought, wouldn't all this fussing about testing and TextBoxes and MsgBoxes be avoided by setting the default value of opt1, opt4, opt7, opt10 and opt 13 to True?
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top