Consulting

Results 1 to 10 of 10

Thread: Aktivate/ deactivate check box

  1. #1
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location

    Aktivate/ deactivate check box

    Hey guys!


    I need your support again.


    It's about Userforms / ComboBox / Check Box.


    I have a table with 10 columns.
    Each column is a combobox


    These are uploaded / initialized like this:


        Dim sheetOne As Worksheet
        Set sheetOne = Sheets("SheetOne")
        Row = 2
       While (sheetOne.Cells(Row, 2) <> "")
            ComboBox_AA.AddItem (sheetOne.Cells(Row, 2))
            Row = Row + 1
        Wend




    So I have 10 combo boxes where the user can select an entry.
    Now I have a checkbox. However, this should not appear or be editable until one of 10 specific selections has been made.
    For this I like to make a last column, which lists the entries.
    Now I just do not know how I implement a suitable loop, which checks whether one of the entries was selected, etc.


    Does anyone have an idea or even an approach?
    Google could not help me yet.




    I hope my words are enough.




    Best regards

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Are these controls on a UserForm or on a Worksheet.

    If these are on a Worksheet, are they Control Toolbox controls or Form controls?

    Note that if they are on a UserForm, then they will be UserForm controls

    Control Toolbox controls and UserForm controls are almost identical, with only subtle differences in their usage. Form controls are completely different from the other two type of controls and must be treated differently.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    Thanks for your answer!

    The controls are all on a UserForm.


    Best regards

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    One way:

    USerForm Code
    Option Explicit
    
    Dim SelectedEntry as String
    'Same Code for each Combobox. Only the Name changes
    Private Sub ComboBoxName_Change()
       SelectedEntry = Me.ComboBoxName.Value
       With Me.CheckBoxName
         .Visible = True
         .SetFocus
       End With
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    Thank you very much for your reply, SamT!

    COuld you please explain further?

    Ok, the first part is the declaration for the variable.

    Is the second part an additional part for the code above?
    How can I choose one of the defined values/ entrys to enable the check box?

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    How can I choose one of the defined values/ entrys to enable the check box?
    I am assuming that all values in all Combo boxes are valid to enable the Check box.

    Is the second part an additional part for the code above?
    That is the code I would put in all ComboBox Change Event Subs.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    [QUOTE=SamT;377122]I am assuming that all values in all Combo boxes are valid to enable the Check box.

    Thanks for your reply!
    Nope, not every value in all Comboboxes are valid to enable the Check box.
    Only the Values from Column I:I are able/ valid, to activate/ enable the check box.
    A part of the values is also in the combo boxes.


    Example:
    Combobox; Values= Column 2, row till end.
    Choose Value= "***"

    If this is also in Column I:I, then the check box should be disabled.

    Do you need a more detailed explanation?

    Here is also an draft:
    example_checkBox.xlsm

  8. #8
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Only the Values from Column I:I are able/ valid... If this is also in Column I:I, then the check box should be disabled.
    ?

    You can select which column in a Combobox can be used.

    Dim Valids as Variant
    Valids = Intersect(Sheets("SomeSheet").UsedRange, Sheets("SomeSheet").Columns("I"))



    For the first situation you described
    For i = Lbound(Valids) to Ubound(Valids)
    If Selection= Valids(i) then CheckBox.Visible = true
    Continue with rest of code
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  9. #9
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    Hey SamT,
    Thanks!

    How can I add the Value (Valids) to the Combobox?
    This approach doesn't works:
        Dim Valids As Variant
    
    
        Valids = Intersect(Sheets("TblOne").UsedRange, Sheets("TblOne").Columns("I"))
            ComboBox_A.Value = Valids
    Is it critical, that every column have an individual UsedRange/ row quantity?

  10. #10
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Valids is an array, a "list." It contains every value in Column I. You need to pick one value. For instance the third value in Column I, in the Valids Array would be, in this particular situation, Valids(3)

    Is it critical, that every column have an individual UsedRange/ row quantity?
    Is it critical that the sky is full of stars? Nope, it just is what it is.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •