66 option buttonsto be disabled

  • Ok, tried this but didn't work, doesn't like the optionbutton&buttonnumber bit.
    I want to be able to clear all the option buttons easily, but am having trouble, don't want to write a massive list of optionbutton1.enabled=false


    Code
    Dim buttonnumber As Integer
    
    
    For buttonnumber = 1 To 66
    OptionButton& buttonnumber.Enabled = False
    Next buttonnumber


    Any help would be super

  • Re: 66 option buttonsto be disabled


    Hi,


    This code should work on a userform.


    If you have checkboxes then change "OptionButton" to "Checkbox"


    HTH


    Charles

    CharlesH


    There are other ways to do this, this is but 1!

  • Re: 66 option buttonsto be disabled


    Awesome thanks!!!


    One more question though...
    The 66 optionbuttons are used to answer yes, no or N/A for 22 questions.
    I want to check that every question is answered before the data is enteres.
    In normal english,
    if optionbutton1 and optionbutton2 and optionbutton3 are all empty then error message.


    Not sure how to write code though...
    :thanx:

  • Re: 66 option buttonsto be disabled


    Alternantively


    You can also use

    Code
    For i=1 to 66
    wsheet.OLEObjects("OptionButton" & CStr(i)).Object.Value)=False
    Next i

    :angrypc:

  • Re: 66 option buttonsto be disabled


    Hi


    Use the following code

    Code
    For i = 1 to 22
    If wsheet.OLEObjects("OptionButton" & CStr(i)).Object.Value)=False and wsheet.OLEObjects("OptionButton" & CStr(i+1)).Object.Value)=False and wsheet.OLEObjects("OptionButton" & CStr(i+2)).Object.Value)=False Then
    Msgbox "answer all Questions
    End IF
    Next i

    :angrypc:

  • Re: 66 option buttonsto be disabled


    tried that Aardarsh but it didn't like it at all...


    the large line of text was all red and it wouldn't run.
    Same with the first suggestion of yours.

  • Re: 66 option buttonsto be disabled


    Hi,
    A quick question are you using a userform, Forms, or ControlTool Box for optionbutton's? If you are using optionbuttons and not CheckBox how are you selecting muti. OptionButton's? Usualy one button will be active and the others will not unless selected. Then the previous button is de-selected.


    Charles

    CharlesH


    There are other ways to do this, this is but 1!

  • Re: 66 option buttonsto be disabled


    Each group of 3 optionbuttons has the same groupname.


    So for Question 1, there is a yes, no and n/a option button that are all in the groupname q1.
    Then in the same form, for question 2 the 3 option buttons are groupname q2.
    This seems to be working nicely!

  • Re: 66 option buttonsto be disabled


    Ok, got this and it checks questions, but how do I get it to stop once it has found what it is looking for?


  • Re: 66 option buttonsto be disabled


    Hi,


    If your msgbox signals what you are looking then put a "Exit Sub" below your MsgBox line.


    Charles

    CharlesH


    There are other ways to do this, this is but 1!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!