Hi all,
First time poster , I'll try to be concise and follow the rules.
I'm trying to loop through entire userform and :
find all comboboxes then pare down their names
then find all checkboxes in a specific frame ,pare down those names and see if they match combobox names
if the combobox name matches the checkbox name ( and that checkbox is true)
then assign values to each of the corresponding ComboBoxes from a default combobox
In short , user enters value in default combobox , then chooses which of the other comboboxes will also have that value with a checkbox.
there are 3 default comboxes and 8 corresponding checkboxes /comboboxes for each.
The code runs without errors but the comboboxes are not getting values from defaults
Any help would really be appreciated ... not sure where things are going wrong?
First time poster , I'll try to be concise and follow the rules.
I'm trying to loop through entire userform and :
find all comboboxes then pare down their names
then find all checkboxes in a specific frame ,pare down those names and see if they match combobox names
if the combobox name matches the checkbox name ( and that checkbox is true)
then assign values to each of the corresponding ComboBoxes from a default combobox
In short , user enters value in default combobox , then chooses which of the other comboboxes will also have that value with a checkbox.
there are 3 default comboxes and 8 corresponding checkboxes /comboboxes for each.
The code runs without errors but the comboboxes are not getting values from defaults
Any help would really be appreciated ... not sure where things are going wrong?
VBA Code:
Private Sub Com2_Click()
Dim ctrl As MSForms.Control
Dim ctrlType1 As String
Dim ctrlType2 As String
Dim ctrlType3 As String
ctrlType1 = "combobox"
ctrlType2 = " Checkbox"
ctrlType3 = " optionbutton"
Dim x1, y1, z, z1, z2, a, a1, a2, v, l, g, p, r As String
For Each ctrl In Me.Controls
If TypeName(ctrl) = ctrlType1 Then
x1 = ctrl.Name
z = Right(x1, 5) ' get last num of char to compare
z1 = Right(x1, 7)
z2 = Right(x1, 8)
r = ctrl.Value
End If
If TypeName(ctrl) = ctrlType2 And Not TypeName(ctrl) = ctrlType3 Then
y = ctrl.Name
a = Right(y, 5) ' get last num of char to compare
a1 = Right(y, 7)
a2 = Right(y, 8)
v = ctrl.Value
End If
If StrComp(z, a, vbTextCompare) = 0 And v = True Then 'combobox and checkbox names match and checkbox is checked
r = CboLite1.Value ' transfer value to matching comboboxes
End If
If StrComp(z1, a1, vbTextCompare) = 0 And v = True Then
r = CboGrills1.Value
End If
If StrComp(z2, a2, vbTextCompare) = 0 And v = True Then
r = CboPrivacy1.Value
End If
Next ctrl
End Sub