multiplecomboboxes False then ..

white_flag

Active Member
Joined
Mar 17, 2010
Messages
331
Hello

I have an user form with 10 comboboxes. I like to put an condition that will check all comboboxes and if one of them has some values then to enable some checkboxes. If all are with .ListIndex = -1 then to locked those checkboxes. I have this code but the problem is that wen in Combo1 is empty and Combo3 >-1 will act like all combos are empty
Code:
Sub freez_cc()

For i = 1 To 10
    If Me.Controls("ComboBox" & i).ListIndex = -1 Then
        Me.Controls("CheckboxA26").Locked = True
        Me.Controls("CheckboxA26").Value = False
        Me.Controls("Checkbox14").Locked = True
        Me.Controls("Checkbox14").Value = False
        Me.Controls("Checkbox16").Locked = True
        Me.Controls("Checkbox16").Value = False
        Me.Controls("Checkbox17").Locked = True
        Me.Controls("Checkbox17").Value = False
        Me.Controls("Checkbox20").Locked = True
        Me.Controls("Checkbox20").Value = False
    Else
        Me.Controls("CheckboxA26").Locked = False
        Me.Controls("Checkbox14").Locked = False
        Me.Controls("Checkbox16").Locked = False
        Me.Controls("Checkbox17").Locked = False
        Me.Controls("Checkbox20").Locked = False
        Exit For

    End If
Next

End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Code:
Sub freez_cc()
Dim NotEmpty As Boolean

                        For i = 1 To 10
                            If Not Me.Controls("ComboBox" & i).Text = "" Then
                                NotEmpty = True
                                    Exit For
                            End If
                        Next

If Not NotEmpty Then

        Me.Controls("CheckboxA26").Locked = True
        Me.Controls("CheckboxA26").Value = False
        Me.Controls("Checkbox14").Locked = True
        Me.Controls("Checkbox14").Value = False
        Me.Controls("Checkbox16").Locked = True
        Me.Controls("Checkbox16").Value = False
        Me.Controls("Checkbox17").Locked = True
        Me.Controls("Checkbox17").Value = False
        Me.Controls("Checkbox20").Locked = True
        Me.Controls("Checkbox20").Value = False
Else
        Me.Controls("CheckboxA26").Locked = False
        Me.Controls("Checkbox14").Locked = False
        Me.Controls("Checkbox16").Locked = False
        Me.Controls("Checkbox17").Locked = False
        Me.Controls("Checkbox20").Locked = False
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

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