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:
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