Posts by willaby

    Hi


    I'm trying to simplify the code below and have previously been able to but am finding my aging brain repeatedly unable to fathom the answer.

    I have a series of Checkboxes (numbered 73 to 99) that I need either a true or false value parsed to a respective cell within a range on a sheet.


    Long hand looks like this:

    Code
    1. 'Loop Through Check Boxes
    2. If CheckBox73.Value = True Then .Range("T8").Value = True Else .Range("T8").Value = False
    3. If CheckBox74.Value = True Then .Range("T9").Value = True Else .Range("T9").Value = False
    4. If CheckBox75.Value = True Then .Range("T10").Value = True Else .Range("T10").Value = False
    5. If CheckBox76.Value = True Then .Range("T11").Value = True Else .Range("T11").Value = False
    6. If CheckBox77.Value = True Then .Range("T12").Value = True Else .Range("T12").Value = False
    7. If CheckBox78.Value = True Then .Range("T13").Value = True Else .Range("T13").Value = False
    8.                 '---- etc etc
    9. If CheckBox99.Value = True Then .Range("T34").Value = True Else .Range("T34").Value = False

    But I know there is a method to use For Loops to loop through both the Checkboxes and the cell range [ .Range("T8:T34") ]


    I tried various iterations of :


    Any pointers of how far off of it working would be gratefully received.


    Thanks all.

    Hi


    I am trying to hide a mixture of labels, textboxes and comboboxes who's name numerator is greater than the listbox count.
    Eg if the listbox count is 4 then controls with a suffix numeral greater than 4 would have visibility set to false and equally made visible if the listbox count changed to include it.


    Code
    1. Listbox1.listcount = 4
    2. Label1.visible = true
    3. Label2.visible = true
    4. Label3.visible = true
    5. Label4.visible = False
    6. Label5.visible = False
    7. Label6.visible = False


    I have attempted to write an appropriate loop for the controls but am uncertain how to capture the control variable being less than / greater than the listbox.listcount.


    Here's what I have:




    Any guidance would be greatly apprecaited.