Disable/enable option button

Rainmanne

Board Regular
Joined
Mar 10, 2016
Messages
120
Office Version
  1. 2013
Platform
  1. Windows
I have a few models which do the same thing but for different sets of data. I am thinking to merge them into one model where a user will have to select a type of the data in order to run either a corresponding sub or a corresponding piece of code in the main sub.

Background: the existing models import data from a spreadsheet generated by a different application. There are two types of the data , which could be presented in two different templates. Also one data type has two subtypes. Also there is an option to replace conditional formatting in the resulted spreadsheet with normal (two avoid issues). So there are currently 4 models and six combinations of the data.

The combined model will have user form controls which will allow a user to select what data type combination they import.

Sorry, I have already posted the background info in the previous thread.

So I first created a userform and to make sure it works I have put message boxes instead of actual macros. The userform is designed as follows:

Option Buttons: Template 1 and Template 2

Combo Box: with two options Public and Private (I am using a combo box because I might add a few more options.

Option Buttons: Tier 1 and Tier 2

Check Box: wipe out the formatting

As only one datatype has tiers ("Private") I want the tier option buttons to grey out when Public is selected.

So I load the userform with tier option buttons disabled.

I want them to get enabled if a Private option is selected in the combo box. But I cannot figure out where to put it.

I've got the following code in the UserForm:

VBA Code:
Private Sub clear_btn_Click()

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
Private Sub cancel_btn_Click()
    Unload Me
    Sheets("Model").CommandButton1.Visible = True
End Sub

Private Sub modelrun_btn_Click()

If radiotempl1.Value = True Then
    If datatype.Value = "Public" Then
        If wipe_format.Value = True Then
                MsgBox "Template 1 Public Model Wipe Out"
        Else
                MsgBox "Template 1 Public Model No Wipe Out"
        End If
    Else
        If radiotier1.Value = True Then
            If wipe_format.Value = True Then
                MsgBox "Template 1 Private Model Tier 1 Wipe Out"
            Else
                MsgBox "Template 1 Private Model Tier 1 No Wipe Out"
            End If
        Else
            If wipe_format.Value = True Then
                MsgBox "Template 1 Private Model Tier 2 Wipe Out"
            Else
                MsgBox "Template 1 Private Model Tier 2 No Wipe Out"
            End If
        End If
    End If
Else
    If datatype.Value = "Public" Then
        If wipe_format.Value = True Then
            MsgBox "Template 2 Public Model Wipe Ou"
        Else
            MsgBox "Template 2 Public Model No Wipe Out"
        End If
    Else
        If radiotier1.Value = True Then
            If wipe_format.Value = True Then
                MsgBox "Tamplate 2 Private Model Tier 1 Wipe Out"
            Else
                MsgBox "Tamplate 2 Private Model Tier 1 No Wipe Out"
            End If
        Else
            If wipe_format.Value = True Then
                MsgBox "Tamplate 2 Private Model Tier 2 Wipe Out"
            Else
                MsgBox "Tamplate 2 Private Model Tier 2 No Wipe Out"
            End If
        End If
    End If
End If
End Sub

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
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I think you'd handle this in the combo change event.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,429
Messages
6,124,844
Members
449,193
Latest member
MikeVol

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