Check that the options in User Form selected

Rainmanne

Board Regular
Joined
Mar 10, 2016
Messages
120
Office Version
  1. 2013
Platform
  1. Windows
I've got a user form to run a code depending on what kind of data I need to upload:

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

Basically, it has two radio buttons, IFT and MMAS, a ComboBox with two options, Public and Private. If an option Private is selected then another combination of radio buttons is activated: tier 1 and tier 2. And there is a checkbox Wipe out Formatting.

I need to make sure that a user first select one of the first radio buttons and an option from the combobox. If they select Private, they have to select tier 1 or tier 2 radio button. The last checkbox should be always selected. I use it for debugging the model. If a required option is not selected, then there should be a message like "Please select a template", and "Please select a datatype" and "Please select a tier". I have found the way to check all the controls but it also checks the inactivated ones. Also I can check individual controls with something like this:
VBA Code:
Private Sub modelrun_btn_Click()

Dim x As Long
x = 0
    For Each xControl In frame_template.Controls
            If TypeName(xControl) = "OptionButton" Then
                If xControl.Value = True Then x = x + 1
            End If
            
    Next xControl
If x = 0 Then MsgBox "You must select a template"

UploadData

End Sub

But I cannot figure out how to make it to check only the required controls.
 
that's the best way but if still stuck & can share copy of your workbook - will have a look

Dave
No, I cannot figure out how to adjust the code 😕. I understand how it works but I cannot change it to make it do what I need.

Here's the link to a dummy workbook with the Userform. Basically, there should be 6 options:

ABC - Public
XYZ - Public
ABC - Private- Tier 1
ABC - Private - Tier 2
XYZ - Private- Tier 1
XYZ - Private - Tier 2

So one of the templates should be selected (ABC or XYZ) and one of the data types from the drop-down box (Public or Private). If Private is selected, then a tier also should be selected.


 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi
I will take a look but my laptop has died & only have access to temp device. I will take a look once my new laptop is all set.

Dave
 
Upvote 0
I've been trying to figure out how to adjust the code to serve my needs but without success so far. I understand that the function checks if the controls are selected but it hangs on the combo box controls and I do not see the way to adjust it without re-writing the code completely.
 
Upvote 0
Hi
solution I posted was just a guess at what I thought you wanted but clearly not quite right - my laptop died & only have limited access to site at moment - once take delivery of new laptop and port files hopefully can assist further is still needed.

Dave
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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