+ Reply to Thread
Results 1 to 17 of 17

Grey out check box based on a selected radio button

  1. #1
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Grey out check box based on a selected radio button

    Hi,
    I have 3 radio buttons and a checkbox.
    The checkbox should only be used when the 1st radio button is selected.
    Is it possible to grey out the check box when the 2nd and 3rd radio buttons are selected.

    Thank you

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Grey out check box based on a selected radio button

    You sure can.

    Right click the radio button 1, choose View Code


    Enter the following code for OptionButton1

    Please Login or Register  to view this content.
    And for buttons 2 and 3:

    Please Login or Register  to view this content.

    See attached if you have questions.
    Attachment 261138

  3. #3
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Re: Grey out check box based on a selected radio button

    im getting an error.
    when i click debug the following is highlighted: If OptionButton2.Enabled = True Then

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Grey out check box based on a selected radio button

    My bad! I was cutting corners; let me lay out the code for each button separately:

    One:
    Please Login or Register  to view this content.
    Two:
    Please Login or Register  to view this content.
    Three:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Re: Grey out check box based on a selected radio button

    the 2nd and 3rd option buttons work great - the checkbox disappears when they're selected.

    however, when the 1st option button is selected, I get the same error as before (Run-time error '424' Object required)
    and the following highlighted in yellow: If OptionButton1.Enabled = True Then

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Grey out check box based on a selected radio button

    Can you confirm that button one is indeed called OptionButton1?

    Click on the object while in design mode and check the label in the upper left corner.

    Attachment 261141

  7. #7
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Re: Grey out check box based on a selected radio button

    its actually optionbutton7 but everything is as it should be.
    ive edited all the numbers in the macro to suit my button numbers.

    As i said, buttons 2 and 3 are working perfectly. cant see why the 1st one isn't

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Grey out check box based on a selected radio button

    however, when the 1st option button is selected, I get the same error as before (Run-time error '424' Object required)
    and the following highlighted in yellow: If OptionButton1.Enabled = True Then
    If OptionButton7.Enabled = True Then

    Does that fix it? Without seeing your full code or a screenshot, my hands are a little tied.

  9. #9
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Re: Grey out check box based on a selected radio button

    thats what im inputing.
    my code is:

    Please Login or Register  to view this content.
    all the numbers are correct

  10. #10
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Grey out check box based on a selected radio button

    And the error is getting stuck on OptionButton1?


    If you are unable to post a copy of your workbook, I would see additional help resolving the RunTime error on the VBA Forum.

    You will likely find more skilled coders there.

  11. #11
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Re: Grey out check box based on a selected radio button

    here you go
    Attached Files Attached Files
    Last edited by tlacloche; 08-27-2013 at 06:59 PM.

  12. #12
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Grey out check box based on a selected radio button

    I see.

    You used Form Controls and I used Active X Controls.

    Two different types of buttons.

    I am not sure how to apply the macros to your versions of the buttons, I will think upon it.

    On Active X buttons, you simply right click them and choose View Code.
    If you convert your buttons to Active X, the LinkedCell is listed under the Properties menu for them.

  13. #13
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Re: Grey out check box based on a selected radio button

    im using a mac. does that help?
    apparently activex cannot be used on excel mac
    Last edited by tlacloche; 08-27-2013 at 07:04 PM.

  14. #14
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Grey out check box based on a selected radio button

    According to your workbook, the buttons are 8, 10, and 12.

    There is no 7.

  15. #15
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Re: Grey out check box based on a selected radio button

    it was 7.
    i then messed up the "7 button" after trying the codes and so deleted it and added a new one

  16. #16
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Grey out check box based on a selected radio button

    When you delete and add it back, it keeps counting.

  17. #17
    Forum Contributor
    Join Date
    03-20-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    474

    Re: Grey out check box based on a selected radio button

    @daffodil - the new button is a different number, so it won't keep counting.

    Maybe I should add to the title "without using activex code".
    Can anyone help?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 08-28-2013, 05:39 AM
  2. [SOLVED] Macro to detect radio button selected and perform action based on selectoin
    By Kistler in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-27-2012, 01:57 AM
  3. Data as per Radio Button selected
    By vijaymohan in forum Excel General
    Replies: 4
    Last Post: 05-04-2012, 01:20 AM
  4. Can't manage to check if radio button is checked
    By Smoka in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2012, 06:54 AM
  5. Replies: 1
    Last Post: 03-20-2006, 01:35 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1