Making sure that all options in User Form are selected

Rainmanne

Board Regular
Joined
Mar 10, 2016
Messages
132
Office Version
  1. 2013
Platform
  1. Windows
I've got a user form designed as follows:

two option buttons grouped

combo box

two option buttons (grouped and activated when one of the options in the combo box is selected)

checkbox

I need to make sure that a user select all this options but the checkbox before clicking OK. The checkbox is selected by default but there are cases when I need to unselect it (but not a user).

I had a similar issue with option buttons on a spreadsheet and with a help from this community I've got the following code:

VBA Code:
Function HasBeenSelected() As Boolean
    Dim i As Long
        For i = 1 To 2
        HasBeenSelected = ActiveSheet.OptionButtons("Option Button " & Choose(i, 2, 4)).Value = xlOn
        If HasBeenSelected Then Exit For
    Next i
    If Not HasBeenSelected Then MsgBox "Please Select the Tier", 48, "Selection Required"
End Function

and
VBA Code:
 If Not HasBeenSelected Then Exit Sub

So I was thinking to repurpose it for the user form, but I've got different types of controls now and one of them (checkbox) should be excluded. So I wonder how I can do it.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
The code for the User Form:
VBA Code:
Private Sub UserForm_Initialize()

'Reset the form
radiotempl1.Value = False
radiotempl2.Value = False
datatype.Clear

With datatype

    .AddItem "Public"
    .AddItem "Private"

End With

radiotier1.Value = False
radiotier2.Value = False
radiotier1.Enabled = False
radiotier2.Enabled = False

wipe_format.Value = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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